PMDF Programmer's Reference Manual


Previous Next Contents Index

2.5.1 Sending a Simple Message

The programs shown in Examples 2-1 and 2-2 demonstrate how to send a simple message to the SYSTEM account. The caller's login command procedure is used as the input source for the body of the message to be sent. The From: address associated with the message is that of the process running the program. The output of these programs is given in Example 2-3. The callouts shown in the first two examples produce the corresponding output shown in the third example.

Example 2-1 Sending a Simple Message (Pascal)

(* send_example1.pas -- Send a simple message *) 
 
[inherit ('pmdf_exe:apidef')] program send_example1; 
 
  var 
    item_index : integer := 0; 
    item_list  : array [1..4] of PMDF_item_list; 
    msgfile    : varying [20] of char := 'SYS$LOGIN:LOGIN.COM'; 
    subject    : varying [20] of char := 'Your login.com file'; 
    to_adr     : varying [20] of char := 'SYSTEM'; 
 
function SYS$EXIT (%immed status : integer := %immed 1) : integer; extern; 
 
(* 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_example1 *) 
  push_str (PMDF_TO,       to_adr); (1)
  push_str (PMDF_SUBJECT,  subject); (2)
  push_str (PMDF_MSG_FILE, msgfile); (3)
  item_list[item_index+1].item_code := 0; 
  SYS$EXIT (PMDF_send ((iaddress (item_list))::PMDF_item_list_ptr)); 
end. (* send_example1 *) 
 

Example 2-2 Sending a Simple Message (C)

/* send_example2.c -- Send a simple message */ 
 
#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 () 
{ 
        PMDF_item_list item_list[4]; 
        int item_index = 0; 
        char *subject  = "Your login procedure"; 
#ifdef  __VMS 
        char *toadr    = "system"; 
        char *msgfile  = "sys$login:login.com"; 
#else 
        char *toadr    = "root"; 
        char *msgfile  = "~/.login"; 
#endif 
 
        ITEM (PMDF_TO,       toadr,   strlen (toadr)); (1)
        ITEM (PMDF_SUBJECT,  subject, strlen (subject)); (2)
        ITEM (PMDF_MSG_FILE, msgfile, strlen (msgfile)); (3)
        ITEM (PMDF_END_LIST, 0,       0); 
        exit (PMDF_send (&item_list)); 
} 
 

Example 2-3 Output of Examples 2-1 and 2-2

Date: 04 Oct 2012 22:24:07 -0700 (PDT) 
From: dominic@yourstruely.com 
Subject: Your login procedure (2)
To: system@yourstruely.com (1)
Message-id: <01GPKF10JIB89LV1WX@yourstruely.com> 
MIME-version: 1.0 
Content-type: TEXT/PLAIN; CHARSET=US-ASCII 
Content-transfer-encoding: 7BIT 
 
$ reply/enable=(tapes) (3)
$ set terminal/insert 
$ define/job dbg$decw$display " " 
$ @mathlib_tools:login.com 


Previous Next Contents Index