CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 1 Data Division 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .title 'Callable Mail Example' ; ; ; C A L L M A I L . D B L ; ; ; Ver/Edit Edit Date By Reason ; ; 1 EXTERNAL FUNCTION 2 MAIL$MAILFILE_OPEN ,%VAL 3 MAIL$MAILFILE_BEGIN ,%VAL 4 MAIL$MAILFILE_CLOSE ,%VAL 5 MAIL$MAILFILE_END ,%VAL 6 MAIL$MAILFILE_COMPRESS ,%VAL 7 MAIL$MESSAGE_BEGIN ,%VAL 8 MAIL$MESSAGE_COPY ,%VAL 9 MAIL$MESSAGE_DELETE ,%VAL 10 MAIL$MESSAGE_END ,%VAL 11 MAIL$MESSAGE_GET ,%VAL 12 MAIL$MESSAGE_INFO ,%VAL 13 MAIL$MESSAGE_MODIFY ,%VAL 14 MAIL$MESSAGE_SELECT ,%VAL 15 MAIL$USER_BEGIN ,%VAL 16 MAIL$USER_END ,%VAL 17 MAIL$USER_GET_INFO ,%VAL 18 MAIL$USER_SET_INFO ,%VAL 19 EXTERNAL FUNCTION 20 SYS$TRNLNM ,%VAL .include '$LNMDEF' library 'sys$library:dblstarlet' .include 'maildef.dib' .include 'mailmsgdef.dib' CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 14 Data Division 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 525 RECORD 526 GROUP IN_ITEM_LIST ,[5]A 527 1 Buff_Length ,I2 528 1 Item_Code ,I2 529 1 Buffer_Addr ,I4 530 1 Return_Length ,I4 531 1 ENDGROUP 532 In_End_Of_List ,I4 533 RECORD 534 GROUP OUT_ITEM_LIST ,[5]A 535 1 Buff_Length ,I2 536 1 Item_Code ,I2 537 1 Buffer_Addr ,I4 538 1 Return_Length ,I4 539 1 ENDGROUP 540 Out_End_Of_List ,I4 541 RECORD 542 LIDL ,I1,4 ;Length of Longword Item Descriptor 543 WIDL ,I1,2 ;Length of Word Item Descriptor 544 MAIL_CONTEXT ,I4 ;Context Returned from Call to MAILFILE routines 545 MESS_CONTEXT ,I4 ;Context Returned from Call to MESSAGE routines 546 USER_CONTEXT ,I4 ;Context Returned from Call to USER routines 547 STATUS ,I4 ;Status Returned from Call 548 MAIL_FILE_NAME ,A8,'MAIL.MAI' 549 NEW_MAIL_FOLDER ,A7,'NEWMAIL' ;Folder for NEWMAIL 550 ERROR_FOLDER ,A6,'ERRORS' ;Folder for messages that ;could not be extracted 551 WASTEBASKET_FOLDER ,A11,'WASTEBASKET' ;Folder for messages that ;will be deleted 552 DAILY_FOLDER ,A9 ;Folder that messages from NEWMAIL folder ;will stored in for one week (Rolling) 553 DAILY_FOLDER_LEN ,I1 ;Length of "DAILY_FOLDER" 554 CURRENT_DAY ,D1 ;Value of current day from function WKDAY 555 DAYS ,[7]A*,'SUNDAY','MONDAY','TUESDAY','WEDNESDAY' & ,'THURSDAY','FRIDAY','SATURDAY' 556 DAYS_LEN ,[7]D1,6,6,7,9,8,6,8 557 BLANK_LINE ,A80 ;Blank Line for text compares 558 MONTHS ,[12]A3,'JAN','FEB','MAR','APR','MAY','JUN' & ,'JUL','AUG','SEP','OCT','NOV','DEC' 559 CURRENT_DATE ,D6 ;Current Date (reformatted YYMMDD) 560 CUR_DATE ,A11 ;Current Date 561 TEXT_CHANNEL ,I1,1 ;Channel number for TEXT File I/O 562 SUBJECT ,A80 ;Subject Text of this Mail Message Header Record 563 SUBJECT_LENGTH ,I2 ;Length of "SUBJECT" 564 TEXT ,A80 ;Message Text of this Mail Message Record 565 TEXT_LENGTH ,I4 ;Length of "TEXT" 566 COUNTER ,I2 ;Counter for loop control 567 MESSAGE_ID ,I4 ;Message ID 568 NUM_MESSAGES ,I4 ;Number of messages selected 569 NUM_PROCESSED ,I2 ;Number of messages processed 570 USER_ACTION ,I4,%XTRNL(FOCRE) 571 FOLDER_CREATED ,A80 ;Name of the folder that was created. 572 FOLDER_CREATED_LENGTH ,I4 ;Length of "FOLDER_CREATED" CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 15 Data Division 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 573 ZERO ,I2,0 ;Zero 574 CURRENT_USERNAME ,A12 ;Current Username 575 CU_LENGTH ,I4 ;Length of "CURRENT_USERNAME" 576 NEW_MESSAGES ,I2 ;New messages count 577 NEWMAIL_COUNTER ,I4 ;NEWMAIL Counter 578 ERROR ,D3 ;Error Number 579 OUTPUT_FILE_SPEC ,A80 ;File Specification of Report File created 580 FIRST_SPACE ,I1 ;Position of first space encountered in string 581 NEW_MAIL_FILE ,A80 ;File Specification of Mail File created ;after the mail file compression operation. 582 NEW_MAIL_FILE_LENGTH ,I1 ;Length of "NEW_MAIL_FILE" 583 MAIL_DIRECTORY ,A127 ;Full directory path that defines the ;location of MAIL.MAI for current user. 584 MAIL_DIRECTORY_LENGTH ,I1 ;Length of "MAIL_DIRECTORY" 585 RECORD MAIL 586 LOG_NAM_TAB_TO_SEARCH ,A17,'LNM$PROCESS_TABLE' 587 MAILADD ,A80 ;Address of mail message for SMAIL 588 MAILSUB ,A80 ;Subject of mail message for SMAIL 589 MAILMSG ,A255 ;Message to be sent by SMAIL 590 ADDRESS ,A6,'MAILTO' ;MAILADD address logical 591 TEXT_ERROR ,A10,'TEXT_ERROR' ;MAILSUB subject logical 592 NO_ADDRESS ,I1 ;Switch indicating no ADDRESS logical 593 NO_SUBJECT ,I1 ;Switch indicating no SUBJECT logical 594 NO_NODE_NAME ,I1 ;Switch indicating no NODE_NAME logical 595 THIS_NODE ,A15 ;Translation of "NODE_NAME" logical 596 NODE_NAME ,A8,'SYS$NODE' ;Current Nodename CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 16 Procedure Division 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 597 PROC 598 XCALL FLAGS (0001000100) ;Do not supersede existing files. 599 CALL TRANSLATE_CURRENT_DATE 600 CALL TRANSLATE_LOGICAL_NAMES 601 CALL TRANSLATE_DAILY_FOLDER_NAME 602 In_Item_List[1].Buff_Length = Zero 603 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 604 In_Item_List[1].Buffer_Addr = Zero 605 In_Item_List[1].Return_Length = Zero 606 In_End_Of_List = Zero 607 Status = %MAIL$MAILFILE_BEGIN (%REF(Mail_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 608 IF (.NOT.%SUCCESS(Status)) XCALL LIB$STOP (%VAL(Status)) CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 17 Obtain Current User Inforamtion 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'Obtain Current User Inforamtion' 609 CALL CLEAR_ITEM_LISTS 610 In_Item_List[1].Buff_Length = Zero 611 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 612 In_Item_List[1].Buffer_Addr = Zero 613 In_Item_List[1].Return_Length = Zero 614 In_End_Of_List = Zero 615 Status = %MAIL$USER_BEGIN (%REF(User_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 616 IF (.NOT.%SUCCESS(Status)) XCALL LIB$STOP (%VAL(Status)) 617 CALL CLEAR_ITEM_LISTS 618 In_Item_List[1].Buff_Length = Zero 619 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 620 In_Item_List[1].Buffer_Addr = Zero 621 In_Item_List[1].Return_Length = Zero 622 Out_Item_List[1].Buff_Length = WIDL 623 Out_Item_List[1].Item_Code = MAIL$_USER_NEW_MESSAGES 624 Out_Item_List[1].Buffer_Addr = %ADDR(NEW_MESSAGES) 625 Out_Item_List[1].Return_Length = Zero 626 Out_Item_List[2].Buff_Length = %SIZE(CURRENT_USERNAME) 627 Out_Item_List[2].Item_Code = MAIL$_USER_RETURN_USERNAME 628 Out_Item_List[2].Buffer_Addr = %ADDR(CURRENT_USERNAME) 629 Out_Item_List[2].Return_Length = %ADDR(CU_LENGTH) 630 Out_Item_List[3].Buff_Length = %SIZE(MAIL_DIRECTORY) 631 Out_Item_List[3].Item_Code = MAIL$_USER_FULL_DIRECTORY 632 Out_Item_List[3].Buffer_Addr = %ADDR(MAIL_DIRECTORY) 633 Out_Item_List[3].Return_Length = %ADDR(MAIL_DIRECTORY_LENGTH) 634 In_End_Of_List = Zero 635 Out_End_Of_List = Zero 636 Status = %MAIL$USER_GET_INFO (%REF(User_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 637 IF (.NOT.%SUCCESS(Status)) XCALL LIB$STOP (%VAL(Status)) 638 IF (.NOT. NEW_MESSAGES) GOTO NO_MESSAGES CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 18 Open User Mail File 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'Open User Mail File' 639 CALL CLEAR_ITEM_LISTS 640 In_Item_List[1].Buff_Length = Zero 641 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 642 In_Item_List[1].Buffer_Addr = Zero 643 In_Item_List[1].Return_Length = Zero 644 In_Item_List[2].Buff_Length = MAIL_DIRECTORY_LENGTH 645 In_Item_List[2].Item_Code = MAIL$_MAILFILE_DEFAULT_NAME 646 In_Item_List[2].Buffer_Addr = %ADDR(MAIL_DIRECTORY) 647 In_Item_List[2].Return_Length = Zero 648 In_Item_List[3].Buff_Length = %SIZE(MAIL_FILE_NAME) 649 In_Item_List[3].Item_Code = MAIL$_MAILFILE_NAME 650 In_Item_List[3].Buffer_Addr = %ADDR(MAIL_FILE_NAME) 651 In_Item_List[3].Return_Length = Zero 652 In_End_Of_List = Zero 653 Status = %MAIL$MAILFILE_OPEN (%REF(Mail_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 654 IF (.NOT.%SUCCESS(Status)) XCALL LIB$STOP (%VAL(Status)) 655 CALL CLEAR_ITEM_LISTS 656 In_Item_List[1].Buff_Length = Zero 657 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 658 In_Item_List[1].Buffer_Addr = Zero 659 In_Item_List[1].Return_Length = Zero 660 In_Item_List[2].Buff_Length = LIDL 661 In_Item_List[2].Item_Code = MAIL$_MESSAGE_FILE_CTX 662 In_Item_List[2].Buffer_Addr = %ADDR(MAIL_CONTEXT) 663 In_Item_List[2].Return_Length = Zero 664 In_End_Of_List = Zero 665 Status = %MAIL$MESSAGE_BEGIN (%REF(Mess_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 666 IF (.NOT.%SUCCESS(Status)) XCALL LIB$STOP (%VAL(Status)) CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 19 Select New Mail Folder 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'Select New Mail Folder' 667 CALL CLEAR_ITEM_LISTS 668 In_Item_List[1].Buff_Length = Zero 669 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 670 In_Item_List[1].Buffer_Addr = Zero 671 In_Item_List[1].Return_Length = Zero 672 In_Item_List[2].Buff_Length = %SIZE(NEW_MAIL_FOLDER) 673 In_Item_List[2].Item_Code = MAIL$_MESSAGE_FOLDER 674 In_Item_List[2].Buffer_Addr = %ADDR(NEW_MAIL_FOLDER) 675 In_Item_List[2].Return_Length = Zero 676 Out_Item_List[1].Buff_Length = LIDL 677 Out_Item_List[1].Item_Code = MAIL$_MESSAGE_SELECTED 678 Out_Item_List[1].Buffer_Addr = %ADDR(NUM_MESSAGES) 679 Out_Item_List[1].Return_Length = Zero 680 In_End_Of_List = Zero 681 Out_End_Of_List = Zero 682 Status = %MAIL$MESSAGE_SELECT (%REF(Mess_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 683 IF (.NOT.%SUCCESS(Status)) XCALL LIB$STOP (%VAL(Status)) 684 NEWMAIL_COUNTER = NUM_MESSAGES CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 20 Select Next Message 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'Select Next Message' 685 NEXT_MESSAGE, 686 INCR NUM_PROCESSED 687 IF (MESSAGE_ID) 688 1 BEGIN 689 1 CLOSE TEXT_CHANNEL 690 1 DECR NEWMAIL_COUNTER 691 1 CALL SET_NEWMAIL_COUNTER 692 1 END 693 CALL CLEAR_ITEM_LISTS 694 CLEAR ERROR 695 IF (NUM_PROCESSED .GT. NUM_MESSAGES) GOTO NO_MORE_MESSAGES 696 CALL CLEAR_ITEM_LISTS 697 CLEAR MESSAGE_ID 698 CLEAR SUBJECT 699 In_Item_List[1].Buff_Length = Zero 700 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 701 In_Item_List[1].Buffer_Addr = Zero 702 In_Item_List[1].Return_Length = Zero 703 In_Item_List[2].Buff_Length = LIDL 704 In_Item_List[2].Item_Code = MAIL$_MESSAGE_NEXT 705 In_Item_List[2].Buffer_Addr = Zero 706 In_Item_List[2].Return_Length = Zero 707 Out_Item_List[1].Buff_Length = %SIZE(SUBJECT) 708 Out_Item_List[1].Item_Code = MAIL$_MESSAGE_SUBJECT 709 Out_Item_List[1].Buffer_Addr = %ADDR(SUBJECT) 710 Out_Item_List[1].Return_Length = %ADDR(SUBJECT_LENGTH) 711 Out_Item_List[2].Buff_Length = LIDL 712 Out_Item_List[2].Item_Code = MAIL$_MESSAGE_CURRENT_ID 713 Out_Item_List[2].Buffer_Addr = %ADDR(MESSAGE_ID) 714 Out_Item_List[2].Return_Length = Zero 715 In_End_Of_List = Zero 716 Out_End_Of_List = Zero 717 Status = %MAIL$MESSAGE_GET (%REF(Mess_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 718 IF (Status .EQ. MAIL$_NOMOREMSG) GOTO NO_MORE_MESSAGES 719 IF (.NOT.%SUCCESS(Status)) XCALL LIB$STOP (%VAL(Status)) 720 IF (.NOT. SUBJECT_LENGTH) GOTO BAD_SUBJECT_TEXT 721 OUTPUT_FILE_SPEC = SUBJECT(1:SUBJECT_LENGTH) 722 OUTPUT_FILE_SPEC(SUBJECT_LENGTH+1:6) = '.TXT;1' 723 ONERROR OPEN_ERROR 724 OPEN (TEXT_CHANNEL,O:S,OUTPUT_FILE_SPEC) 725 OFFERROR CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 22 Get Next Line of Message and Extract to TEXT 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'Get Next Line of Message and Extract to TEXT File' 726 NEXT_LINE_OF_MESSAGE, 727 CALL CLEAR_ITEM_LISTS 728 CLEAR TEXT 729 In_Item_List[1].Buff_Length = Zero 730 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 731 In_Item_List[1].Buffer_Addr = Zero 732 In_Item_List[1].Return_Length = Zero 733 In_Item_List[2].Buff_Length = LIDL 734 In_Item_List[2].Item_Code = MAIL$_MESSAGE_CONTINUE 735 In_Item_List[2].Buffer_Addr = Zero 736 In_Item_List[2].Return_Length = Zero 737 Out_Item_List[1].Buff_Length = %SIZE(TEXT) 738 Out_Item_List[1].Item_Code = MAIL$_MESSAGE_RECORD 739 Out_Item_List[1].Buffer_Addr = %ADDR(TEXT) 740 Out_Item_List[1].Return_Length = %ADDR(TEXT_LENGTH) 741 In_End_Of_List = Zero 742 Out_End_Of_List = Zero 743 Status = %MAIL$MESSAGE_GET (%REF(Mess_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 744 IF (Status .EQ. MAIL$_NOMOREREC) GOTO END_OF_TEXT_EXTRACT 745 IF ((.NOT.TEXT_LENGTH) .OR. TEXT .EQ. BLANK_LINE) GOTO NEXT_MESSAGE 746 IF (TEXT_LENGTH) THEN WRITES (TEXT_CHANNEL,TEXT(1:TEXT_LENGTH)) 747 ELSE WRITES (TEXT_CHANNEL,'') 748 IF (Status .EQ. MAIL$_MSGTEXT) GOTO NEXT_LINE_OF_MESSAGE 749 IF (.NOT.%SUCCESS(Status)) XCALL LIB$STOP (%VAL(Status)) 750 END_OF_TEXT_EXTRACT, 751 CALL MOVE_TO_DAILY_FOLDER 752 CLOSE TEXT_CHANNEL 753 GOTO NEXT_MESSAGE .subtitle 'Reset New Mail Count' 754 NO_MORE_MESSAGES, 755 CLEAR NEWMAIL_COUNTER 756 CALL SET_NEWMAIL_COUNTER 757 CALL COMPRESS 758 NO_MESSAGES, 759 CALL CLEANUP 760 CLOSE TEXT_CHANNEL ;Just in case.... 761 END_OF_JOB, 762 STOP CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 25 Clear Item List Arrays 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'Clear Item List Arrays' 763 CLEAR_ITEM_LISTS, 764 CLEAR Counter 765 FOR Counter FROM 1 THRU 5 766 1 BEGIN 767 1 CLEAR In_Item_list[Counter].Buff_Length 768 1 CLEAR In_Item_List[Counter].Item_Code 769 1 CLEAR In_Item_List[Counter].Buffer_Addr 770 1 CLEAR In_Item_List[Counter].Return_Length 771 1 CLEAR Out_Item_list[Counter].Buff_Length 772 1 CLEAR Out_Item_List[Counter].Item_Code 773 1 CLEAR Out_Item_List[Counter].Buffer_Addr 774 1 CLEAR Out_Item_List[Counter].Return_Length 775 1 END 776 RETURN CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 26 Move Message from NEWMAIL to DAILY Folder 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'Move Message from NEWMAIL to DAILY Folder' 777 MOVE_TO_DAILY_FOLDER, 778 In_Item_List[1].Buff_Length = Zero 779 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 780 In_Item_List[1].Buffer_Addr = Zero 781 In_Item_List[1].Return_Length = Zero 782 In_Item_List[2].Buff_Length = LIDL 783 In_Item_List[2].Item_Code = MAIL$_MESSAGE_ID 784 In_Item_List[2].Buffer_Addr = %ADDR(MESSAGE_ID) 785 In_Item_List[2].Return_Length = Zero 786 In_Item_List[3].Buff_Length = LIDL 787 In_Item_List[3].Item_Code = MAIL$_MESSAGE_FOLDER_ACTION 788 In_Item_List[3].Buffer_Addr = USER_ACTION 789 In_Item_List[3].Return_Length = Zero 790 In_Item_List[4].Buff_Length = DAILY_FOLDER_LEN 791 In_Item_List[4].Item_Code = MAIL$_MESSAGE_FOLDER 792 In_Item_List[4].Buffer_Addr = %ADDR(DAILY_FOLDER(1:DAILY_FOLDER_LEN)) 793 In_Item_List[4].Return_Length = Zero 794 In_Item_List[5].Buff_Length = LIDL 795 In_Item_List[5].Item_Code = MAIL$_MESSAGE_DELETE 796 In_Item_List[5].Buffer_Addr = Zero 797 In_Item_List[5].Return_Length = Zero 798 Out_Item_List[1].Buff_Length = LIDL 799 Out_Item_List[1].Item_Code = MAIL$_MESSAGE_FOLDER_CREATED 800 Out_Item_List[1].Buffer_Addr = %ADDR(FOLDER_CREATED) 801 Out_Item_List[1].Return_Length = %ADDR(FOLDER_CREATED_LENGTH) 802 In_End_Of_List = Zero 803 Out_End_Of_List = Zero 804 Status = %MAIL$MESSAGE_COPY (%REF(Mess_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 805 IF (.NOT.%SUCCESS(Status)) XCALL LIB$STOP (%VAL(Status)) 806 RETURN CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 27 Set NEWMAIL message counter 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'Set NEWMAIL message counter' 807 SET_NEWMAIL_COUNTER, 808 IF (NEWMAIL_COUNTER .LT. 0) CLEAR NEWMAIL_COUNTER 809 CALL CLEAR_ITEM_LISTS 810 In_Item_List[1].Buff_Length = Zero 811 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 812 In_Item_List[1].Buffer_Addr = Zero 813 In_Item_List[1].Return_Length = Zero 814 In_Item_List[2].Buff_Length = CU_LENGTH 815 In_Item_List[2].Item_Code = MAIL$_USER_USERNAME 816 In_Item_List[2].Buffer_Addr = %ADDR(CURRENT_USERNAME(1:CU_LENGTH)) 817 In_Item_List[2].Return_Length = Zero 818 In_Item_List[3].Buff_Length = WIDL 819 In_Item_List[3].Item_Code = MAIL$_USER_SET_NEW_MESSAGES 820 In_Item_List[3].Buffer_Addr = %ADDR(NEWMAIL_COUNTER) 821 In_Item_List[3].Return_Length = Zero 822 In_End_Of_List = Zero 823 Status = %MAIL$USER_SET_INFO (%REF(User_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 824 IF (.NOT.%SUCCESS(Status)) XCALL LIB$STOP (%VAL(Status)) 825 RETURN CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 28 Compress Mail File 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'Compress Mail File' 826 COMPRESS, 827 CALL CLEAR_ITEM_LISTS 828 In_Item_List[1].Buff_Length = %SIZE(MAIL_DIRECTORY) 829 In_Item_List[1].Item_Code = MAIL$_MAILFILE_DEFAULT_NAME 830 In_Item_List[1].Buffer_Addr = %ADDR(MAIL_DIRECTORY) 831 In_Item_List[1].Return_Length = Zero 832 Out_Item_List[1].Buff_Length = %SIZE(NEW_MAIL_FILE) 833 Out_Item_List[1].Item_Code = MAIL$_MAILFILE_RESULTSPEC 834 Out_Item_List[1].Buffer_Addr = %ADDR(NEW_MAIL_FILE) 835 Out_Item_List[1].Return_Length = %ADDR(NEW_MAIL_FILE_LENGTH) 836 In_End_Of_List = Zero 837 Out_End_Of_List = Zero 838 Status = %MAIL$MAILFILE_COMPRESS (%REF(Mail_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 839 IF (.NOT.%SUCCESS(Status)) XCALL LIB$STOP (%VAL(Status)) 840 RETURN CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 29 Clean Up and Exit 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'Clean Up and Exit' 841 CLEANUP, 842 Status = %MAIL$USER_END (%REF(User_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 843 CALL CLEAR_ITEM_LISTS 844 In_Item_List[1].Buff_Length = Zero 845 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 846 In_Item_List[1].Buffer_Addr = Zero 847 In_Item_List[1].Return_Length = Zero 848 In_End_Of_List = Zero 849 Status = %MAIL$MESSAGE_END (%REF(Mess_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 850 CALL CLEAR_ITEM_LISTS 851 In_Item_List[1].Buff_Length = Zero 852 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 853 In_Item_List[1].Buffer_Addr = Zero 854 In_Item_List[1].Return_Length = Zero 855 In_End_Of_List = Zero 856 Status = %MAIL$MAILFILE_END (%REF(Mail_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 857 CALL CLEAR_ITEM_LISTS 858 In_Item_List[1].Buff_Length = Zero 859 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 860 In_Item_List[1].Buffer_Addr = Zero 861 In_Item_List[1].Return_Length = Zero 862 In_End_Of_List = Zero 863 Status = %MAIL$MAILFILE_CLOSE (%REF(Mail_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 864 RETURN CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 30 Translate Daily Folder Name 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'Translate Daily Folder Name' 865 TRANSLATE_DAILY_FOLDER_NAME, 866 Current_Day = %WKDAY 867 DAILY_FOLDER = DAYS[Current_Day] 868 DAILY_FOLDER_LEN = DAYS_LEN[Current_Day] 869 RETURN .subtitle 'Translate Current Date' 870 TRANSLATE_CURRENT_DATE, 871 Cur_Date = %DATE 872 Current_Date(1,2) = Cur_Date(10,11) 873 Current_Date(5,6) = Cur_Date(1,2) 874 TRANSLATE_MONTH, 875 FOR Counter FROM 1 THRU 12 876 1 BEGIN 877 1 IF (Cur_Date(4,6) .EQ. Months[Counter]) EXITLOOP 878 1 END 879 Current_Date(3,4) = Counter 880 RETURN CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 32 Translate Logical Names 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'Translate Logical Names' 881 TRANSLATE_LOGICAL_NAMES, 882 CALL CLEAR_ITEM_LISTS 883 In_Item_List[1].Buff_Length = %SIZE(MAILADD) 884 In_Item_List[1].Item_Code = LNM$_STRING 885 In_Item_List[1].Buffer_Addr = %ADDR(MAILADD) 886 In_Item_List[1].Return_Length = 0 887 In_End_Of_List = 0 888 Status = %SYS$TRNLNM(,LOG_NAM_TAB_TO_SEARCH,ADDRESS,,%REF(In_Item_List)) 889 IF (.NOT.%SUCCESS(STATUS)) NO_ADDRESS = 1 890 CALL CLEAR_ITEM_LISTS 891 In_Item_List[1].Buff_Length = %SIZE(THIS_NODE) 892 In_Item_List[1].Item_Code = LNM$_STRING 893 In_Item_List[1].Buffer_Addr = %ADDR(THIS_NODE) 894 In_Item_List[1].Return_Length = 0 895 In_End_Of_List = 0 896 Status = %SYS$TRNLNM(,LOG_NAM_TAB_TO_SEARCH,NODE_NAME,,%REF(In_Item_List)) 897 IF (.NOT.%SUCCESS(STATUS)) NO_NODE_NAME = 1 898 CALL CLEAR_ITEM_LISTS 899 In_Item_List[1].Buff_Length = %SIZE(MAILSUB) 900 In_Item_List[1].Item_Code = LNM$_STRING 901 In_Item_List[1].Buffer_Addr = %ADDR(MAILSUB) 902 In_Item_List[1].Return_Length = 0 903 In_End_Of_List = 0 904 Status = %SYS$TRNLNM(,LOG_NAM_TAB_TO_SEARCH,TEXT_ERROR,,%REF(In_Item_List)) 905 IF (.NOT.%SUCCESS(STATUS)) NO_SUBJECT = 1 906 RETURN CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 33 Move Message from NEWMAIL to ERRORS Folder 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'Move Message from NEWMAIL to ERRORS Folder' 907 MOVE_TO_ERROR_FOLDER, 908 In_Item_List[1].Buff_Length = Zero 909 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 910 In_Item_List[1].Buffer_Addr = Zero 911 In_Item_List[1].Return_Length = Zero 912 In_Item_List[2].Buff_Length = LIDL 913 In_Item_List[2].Item_Code = MAIL$_MESSAGE_ID 914 In_Item_List[2].Buffer_Addr = %ADDR(MESSAGE_ID) 915 In_Item_List[2].Return_Length = Zero 916 In_Item_List[3].Buff_Length = LIDL 917 In_Item_List[3].Item_Code = MAIL$_MESSAGE_FOLDER_ACTION 918 In_Item_List[3].Buffer_Addr = USER_ACTION 919 In_Item_List[3].Return_Length = Zero 920 In_Item_List[4].Buff_Length = %SIZE(ERROR_FOLDER) 921 In_Item_List[4].Item_Code = MAIL$_MESSAGE_FOLDER 922 In_Item_List[4].Buffer_Addr = %ADDR(ERROR_FOLDER) 923 In_Item_List[4].Return_Length = Zero 924 In_Item_List[5].Buff_Length = LIDL 925 In_Item_List[5].Item_Code = MAIL$_MESSAGE_DELETE 926 In_Item_List[5].Buffer_Addr = Zero 927 In_Item_List[5].Return_Length = Zero 928 Out_Item_List[1].Buff_Length = LIDL 929 Out_Item_List[1].Item_Code = MAIL$_MESSAGE_FOLDER_CREATED 930 Out_Item_List[1].Buffer_Addr = %ADDR(FOLDER_CREATED) 931 Out_Item_List[1].Return_Length = %ADDR(FOLDER_CREATED_LENGTH) 932 In_End_Of_List = Zero 933 Out_End_Of_List = Zero 934 Status = %MAIL$MESSAGE_COPY (%REF(Mess_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 935 IF (.NOT.%SUCCESS(Status)) XCALL LIB$STOP (%VAL(Status)) 936 RETURN CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 34 Move Message from current folder to WATSEBASK 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'Move Message from current folder to WATSEBASKET Folder' 937 MOVE_TO_WASTEBASKET_FOLDER, 938 In_Item_List[1].Buff_Length = Zero 939 In_Item_List[1].Item_Code = MAIL$_NOSIGNAL 940 In_Item_List[1].Buffer_Addr = Zero 941 In_Item_List[1].Return_Length = Zero 942 In_Item_List[2].Buff_Length = LIDL 943 In_Item_List[2].Item_Code = MAIL$_MESSAGE_ID 944 In_Item_List[2].Buffer_Addr = %ADDR(MESSAGE_ID) 945 In_Item_List[2].Return_Length = Zero 946 In_Item_List[3].Buff_Length = LIDL 947 In_Item_List[3].Item_Code = MAIL$_MESSAGE_FOLDER_ACTION 948 In_Item_List[3].Buffer_Addr = USER_ACTION 949 In_Item_List[3].Return_Length = Zero 950 In_Item_List[4].Buff_Length = %SIZE(WASTEBASKET_FOLDER) 951 In_Item_List[4].Item_Code = MAIL$_MESSAGE_FOLDER 952 In_Item_List[4].Buffer_Addr = %ADDR(WASTEBASKET_FOLDER) 953 In_Item_List[4].Return_Length = Zero 954 In_Item_List[5].Buff_Length = LIDL 955 In_Item_List[5].Item_Code = MAIL$_MESSAGE_DELETE 956 In_Item_List[5].Buffer_Addr = Zero 957 In_Item_List[5].Return_Length = Zero 958 Out_Item_List[1].Buff_Length = LIDL 959 Out_Item_List[1].Item_Code = MAIL$_MESSAGE_FOLDER_CREATED 960 Out_Item_List[1].Buffer_Addr = %ADDR(FOLDER_CREATED) 961 Out_Item_List[1].Return_Length = %ADDR(FOLDER_CREATED_LENGTH) 962 In_End_Of_List = Zero 963 Out_End_Of_List = Zero 964 Status = %MAIL$MESSAGE_COPY (%REF(Mess_Context) & ,%REF(In_Item_list) & ,%REF(Out_Item_List)) 965 IF (.NOT.%SUCCESS(Status)) XCALL LIB$STOP (%VAL(Status)) 966 RETURN CALLMAIL Callable Mail Example 5-DEC-1990 19:40:29 VAX DIBOL V4.1-00 Page 35 File Open Error 5-DEC-1990 19:40:17 DUB0:[DECUS]CALLMAIL.DBL;1 .subtitle 'File Open Error' 967 OPEN_ERROR, 968 OFFERROR 969 Error = %ERROR ; Possibilities ; ; 17 $ERR_FILSPC - Illegal Characters in File Specification ; ; 22 $ERR_IOFAIL - Hardware problem. ; ; 24 $ERR_NOSPAC - No space for file ; ; 32 $ERR_REPLAC - Already Exists ; 970 CALL CLEAR_ITEM_LISTS 971 CALL MOVE_TO_ERROR_FOLDER ;Decide on content of message to be sent to system manager. ;and send it. 972 IF (NO_ADDRESS) GOTO NEXT_MESSAGE 973 MAILADD = ADDRESS 974 IF (NO_SUBJECT) 975 1 BEGIN 976 1 TEXT_ERROR = "No TEXT_ERROR logical at node " 977 1 TEXT_ERROR(31:15) = NODE_NAME 978 1 END 979 MAILSUB = TEXT_ERROR 980 CLEAR MAILMSG 981 MAILMSG = 'Error # ??? creating output file for this message -> ' 982 MAILMSG(54:80) = SUBJECT 983 MAILMSG(9:3) = ERROR, 'XXX' 984 XCALL SMAIL (MAILADD,MAILSUB,MAILMSG) 985 GOTO NEXT_MESSAGE .subtitle 'Bad Subject Text' 986 BAD_SUBJECT_TEXT, 987 Error = 99 ;This is actually reserved by VAX Dibol, ;however, we will use to flag error field. 988 CALL CLEAR_ITEM_LISTS 989 CALL MOVE_TO_ERROR_FOLDER ;Decide on content of message to be sent to system manager. ;and send it. 990 IF (NO_ADDRESS) GOTO NEXT_MESSAGE 991 MAILADD = ADDRESS 992 IF (NO_SUBJECT) 993 1 BEGIN 994 1 TEXT_ERROR = "No TEXT_ERROR logical at node " 995 1 TEXT_ERROR(31:15) = NODE_NAME 996 1 END 997 MAILSUB = TEXT_ERROR 998 CLEAR MAILMSG 999 MAILMSG = 'Error in structure of subject field for this message -> ' 1000 MAILMSG(57:80) = SUBJECT 1001 XCALL SMAIL (MAILADD,MAILSUB,MAILMSG) 1002 GOTO NEXT_MESSAGE No errors detected DIBOL/NOSTAND/OBJECT/LIS CALLMAIL