Previous | Contents | Index |
The programs given in Examples 2-8 and 2-9 demonstrate three concepts:
The following items of note are identified with callouts in each of the two programs:
Example 2-8 Multiple Addresses (Pascal) |
---|
(* send_example5.pas -- Send a message to multiple recipients, including FAX recipients *) [inherit ('pmdf_exe:apidef')] program send_example5 (output); type string = varying [ALFA_SIZE] of char; var item_index : integer := 0; i, stat : integer; item_list : array [1..19] of PMDF_item_list; msgfile : string := 'sys$login:login.com'; subject : string := 'PMDF callable SEND example: sending a FAX'; to_adr_1 : [static] string := 'system'; (1) to_adr_2 : [static] string := 'bob@example.com'; (1) cc_adr_1 : [static] string := 'sue@example.com'; (1) (* First FAX address *) fn_1 : string := '1-714-555-5319'; (* REQUIRED *) domain_1 : string := 'text-fax.example.com'; (* REQUIRED *) at_1 : string := 'Mrochek Freed'; o_1 : string := 'Example Software, LLC'; ou1_1 : string := '9 Main Street'; ou2_1 : string := 'Springfield, USA'; tn_1 : string := '(508) 555-1111'; fax_adr_1 : [static] string; (2) (* Second FAX address *) fn_2 : string := '1-800-555-1212'; (* REQUIRED *) domain_2 : string := 'text-fax.example.com'; (* REQUIRED *) at_2 : string := '800 Directory Assistance'; fax_adr_2 : [static] string; (2) function SYS$EXIT (%immed status : integer := %immed 1) : integer; extern; (* Push an option oriented entry onto the item list *) procedure push_opt (code : integer); begin (* push_opt *) item_index := succ (item_index); with item_list[item_index] do begin item_code := code; item_address := nil; item_length := 0; end; (* with *) end; (* push_opt *) (* Push an string oriented entry onto the item list *) procedure push_str (code : integer; var str : varying [len] of char); begin (* push_str *) item_index := succ (item_index); with item_list[item_index] do begin item_code := code; item_address := (iaddress (str.body))::$stringptr; item_length := str.length; end; (* with *) end; (* push_str *) begin (* send_example5 *) (* Specify the Subject: header line and message input source *) push_str (PMDF_SUBJECT, subject); push_str (PMDF_MSG_FILE, msgfile); (* Return per address status/error messages *) push_opt (PMDF_ADDRESS_STATUS); (3) (* Specify regular To: and Cc: addresses *) push_str (PMDF_TO, to_adr_1); (4) push_str (PMDF_TO, to_adr_2); (4) push_str (PMDF_CC, cc_adr_1); (4) (* Specify the first FAX address *) push_str (PMDF_FAX_TO, fax_adr_1); (5) push_str (PMDF_FAX_DOMAIN, domain_1); push_str (PMDF_FAX_FN, fn_1); push_str (PMDF_FAX_AT, at_1); push_str (PMDF_FAX_O, o_1); push_str (PMDF_FAX_OU, ou1_1); push_str (PMDF_FAX_OU, ou2_1); push_str (PMDF_FAX_TN, tn_1); (* Specify the second FAX address *) push_str (PMDF_FAX_BCC, fax_adr_2); (6) push_str (PMDF_FAX_DOMAIN, domain_2); push_str (PMDF_FAX_FN, fn_2); push_str (PMDF_FAX_AT, at_2); (* Now terminate the item list *) push_opt (PMDF_END_LIST); (* And send the message *) stat := PMDF_send ((iaddress (item_list))::PMDF_item_list_ptr); (7) (* Display the address status messages provided that no error other than PMDF__HOST has occurred. *) if odd (stat) or (stat = PMDF__HOST) then for i := 1 to item_index do (8) with item_list[i] do case item_code of PMDF_TO, PMDF_CC, PMDF_BCC, PMDF_FAX_TO, PMDF_FAX_CC, PMDF_FAX_BCC, PMDF_PRT_TO, PMDF_PRT_CC, PMDF_PRT_BCC : writeln (substr (item_address^, 1, abs (item_length))); otherwise begin end; end; (* case, with, for, if *) (* Now exit *) SYS$EXIT (stat); end. (* send_example5 *) |
Example 2-9 Multiple Addresses (C) |
---|
/* send_example6.c -- Send a message to multiple recipients, including FAX recipients */ #include <stdio.h> #ifdef __VMS #include "pmdf_com:apidef.h" #else #include "/pmdf/include/apidef.h" #endif /* Push an entry onto the item list */ #define ITEM(item,adr,len) item_list[item_index].item_code = (item); \ item_list[item_index].item_address = (char *)(adr); \ item_list[item_index].item_length = (len); \ item_index++ main () { int item_index = 0, stat; PMDF_item_list item_list[19]; char *subject = "PMDF callable SEND example: sending a FAX"; char to_adr_2[ALFA_SIZE+1] = "bob@example.com"; (1) char cc_adr_1[ALFA_SIZE+1] = "sue@example.com"; (1) #ifdef __VMS char *msgfile = "sys$login:login.com"; char to_adr_1[ALFA_SIZE+1] = "system"; #else char *msgfile = "~/.login"; char to_adr_1[ALFA_SIZE+1] = "root"; #endif /* First FAX address */ char *fn_1 = "1-714-555-5319"; /* REQUIRED */ char *domain_1 = "text-fax.example.com"; /* REQUIRED */ char *at_1 = "Mrochek Freed"; char *o_1 = "Example Software, LLC"; char *ou1_1 = "9 Main Street"; char *ou2_1 = "Springfield, USA"; char *tn_1 = "(508) 555-1111"; char fax_adr_1[ALFA_SIZE+1]; (2) /* Second FAX address */ char *fn_2 = "1-800-555-1212"; /* REQUIRED */ char *domain_2 = "text-fax.example.com"; /* REQUIRED */ char *at_2 = "800 Directory Assistance"; char fax_adr_2[ALFA_SIZE+1]; (2) /* Specify the Subject: header line and message input source */ ITEM (PMDF_SUBJECT, subject, strlen (subject)); ITEM (PMDF_MSG_FILE, msgfile, strlen (msgfile)); /* Return per address status/error messages */ ITEM (PMDF_ADDRESS_STATUS, 0, 0); (3) /* Specify regular To: and Cc: addresses */ ITEM (PMDF_TO, to_adr_1, strlen (to_adr_1)); (4) ITEM (PMDF_TO, to_adr_2, strlen (to_adr_2)); (4) ITEM (PMDF_CC, cc_adr_1, strlen (cc_adr_1)); (4) /* Specify the first FAX address */ ITEM (PMDF_FAX_TO, fax_adr_1, 0); (5) ITEM (PMDF_FAX_DOMAIN, domain_1, strlen (domain_1)); ITEM (PMDF_FAX_FN, fn_1, strlen (fn_1)); ITEM (PMDF_FAX_AT, at_1, strlen (at_1)); ITEM (PMDF_FAX_O, o_1, strlen (o_1)); ITEM (PMDF_FAX_OU, ou1_1, strlen (ou1_1)); ITEM (PMDF_FAX_OU, ou2_1, strlen (ou2_1)); ITEM (PMDF_FAX_TN, tn_1, strlen (tn_1)); /* Specify the second FAX address */ ITEM (PMDF_FAX_BCC, fax_adr_2, 0); (6) ITEM (PMDF_FAX_DOMAIN, domain_2, strlen (domain_2)); ITEM (PMDF_FAX_FN, fn_2, strlen (fn_2)); ITEM (PMDF_FAX_AT, at_2, strlen (at_2)); /* Now terminate the item list */ ITEM (PMDF_END_LIST, 0, 0); /* And send the message */ stat = PMDF_send (&item_list); (7) /* Display the address status messages provided that no error other than PMDF__HOST has occurred. */ if ((1 & stat) || stat == PMDF__HOST) { (8) int i, j; for (i = 0; i < item_index; i ++) { switch (item_list[i].item_code) { case PMDF_TO : case PMDF_CC : case PMDF_BCC : case PMDF_FAX_TO : case PMDF_FAX_CC : case PMDF_FAX_BCC : case PMDF_PRT_TO : case PMDF_PRT_CC : case PMDF_PRT_BCC : j = abs (item_list[i].item_length); item_list[i].item_address[j] = '\0'; printf ("%s\n", item_list[i].item_address); break; default : break; } } } exit (stat); } |
Example 2-10 Address Status Messages Produced by Examples 2-8 and 2-9 |
---|
address okay: system address okay: bob@example.com address okay: sue@example.com address okay: "/FN=1-714-555-5319/AT=John Jones/O=Example Software, LLC ./OU=9 Main Street/OU=Springfield, USA/TN=(508) 555-1111/" @text-fax.example.com address okay: "/FN=1-800-555-1212/AT=800 Directory Assistance/" @text-fax.example.com |
Previous | Next | Contents | Index |