!Last Modified: 15-JUN-1989 11:31:28.41, By: FLEMING procedure eve_mailx_module_init eve$x_mail_foreign := ""; endprocedure Procedure eve_attach_mail local username; username := call_user(rtp$calluser_getjpi,"USERNAME"); username := username+"_MAIL"; attach(username); endprocedure Procedure rlb_forward_edit local loc$save_buffer, indent_marker, next_pos; on_error position(loc$save_buffer); set(screen_update,on); return; endon_error; indent_marker := '>'; loc$save_buffer:=current_buffer; set(screen_update,off); position(beginning_of(current_buffer)); loop exitif end_of(current_buffer) = mark(none); copy_text(indent_marker); next_pos := search(line_begin,forward); exitif next_pos = 0; position(beginning_of(next_pos)); endloop; set(screen_update,on); endprocedure Procedure rlb_include_signature_file ! ! looks for logical SIGNATURE then SYS$LOGIN:.SIGNATURE ! In order to have it look for something besides the default do ! a DEFINE/JOB SIGNATURE ! local loc$save_buffer, signature_file; ! see if there is a logical name pointing to a signature file available signature_file := call_user(rtp$calluser_trnlnm,"SIGNATURE"); if signature_file = '' then ! there wasn't a logical name so look for the default one signature_file := file_search('sys$login:.signature;'); endif; ! do we have any kind of signature file now? if signature_file = '' then return else position(end_of(current_buffer)); eve_include_file(signature_file); position(loc$save_buffer); endif; return; endprocedure Procedure RLB_MAIL_MESSAGE_INIT ! ! Fix up a message with brackets and SIGNATURE file ! local place_hold, text_end, new_buffer, mess_pref, init_heading, init_footing ; update(current_window); place_hold := mark(none); text_end := end_of(current_buffer); new_buffer := get_info (current_buffer, "record_count") = 0 ; if new_buffer then copy_text('Message Created @ '+fao("!%D",0)); split_line; else ! ! we have either a forwarded or reply or something ! position(beginning_of(current_buffer)); ! see if the buffer has a "FROM:" somebody in it if Search('from'+':',forward) = 0 then ! ! if not, we must be sending a file to somebody ! mess_pref := 'Message'; init_heading := ' 8< cut here '; init_footing := ' End of Text to Cut '; else ! if it was From: someone we are forwarding or replying mess_pref := 'Forwarded/Reply'; init_heading := ' Original Message '; init_footing := ' End of Original Message '; endif; ! Put in the description at the top copy_text(mess_pref+' created @ '+fao("!%D",0)); split_line; ! ! put in the header and trailer bars ! copy_text(rlb_center('=',init_heading,78)); split_line; position(text_end); copy_text(rlb_center('=',init_footing,78)); split_line; endif; ! Throw in the signature file at the end rlb_include_signature_file; endprocedure Procedure eve_mailx(;mail_buffer,mail_recipient,mail_subject) local prompt, loc_buffer_name, loc_mail_subject,loc_mail_recipient, mess_lines, save_mark, err_pat, temp_range, temp_mark, first_line,last_line ; on_error if (error = tpu$_noselect) or (error = tpu$_selrangezero) then temp_range := 0 ; else if (error = tpu$_sendfail) or (error = tpu$_noprocess) then message('Error while sending MAIL -- subprocess died'); else message(fao('Failed to complete procedure EVE_MAILX, '+ 'error at line !UL',error_line)); endif; position(save_mark); update(current_window); return(error); endif; endon_error; eve_toggle_white_map; save_mark := current_buffer; loc_buffer_name := get_info(current_buffer,"name"); first_line := 1; temp_range := select_range; if temp_range <> 0 then ! ! they selected a range -- now MAIL it ! find out how long the range is ! position(beginning_of(temp_range)); loc_buffer_name := get_info(current_buffer,"name"); first_line := eve_return_line(mark(none)); position(end_of(temp_range)); last_line := eve_return_line(mark(none)); if first_line <> last_line then mess_lines := fao('lines !UL->!UL',first_line,last_line); else mess_lines := fao('line !UL',first_line); endif; loc_mail_buffer := temp_range; temp_range := 0; eve$x_select_position := 0; else ! not mailing a range if ((mail_buffer = eve$kt_null) or (get_info(mail_buffer,"type") = UNSPECIFIED)) then ! if no mail buffer supplied prompt := "Enter buffer to mail =current buffer: "; loc_buffer_name := read_line(prompt); if (loc_buffer_name = eve$kt_null) then loc_mail_buffer := get_info(buffer,"current"); loc_buffer_name := get_info(loc_mail_buffer,"name"); edit(loc_buffer_name,upper); else ! user specified a buffer name get the buffer ptr eve$cleanse_string(loc_buffer_name); edit(loc_buffer_name,upper); ! return ptr loc_mail_buffer := eveplus_find_buffer(loc_buffer_name); if (loc_mail_buffer = 0) then message(fao( "Buffer !AS not found -- no message sent", loc_buffer_name)); return; endif; loc_buffer_name := get_info(loc_mail_buffer,"name"); endif; else ! supplied as an arg loc_mail_buffer := mail_buffer; endif; last_line := get_info(loc_mail_buffer,"record_count"); mess_lines := fao('!UL line!%S',last_line); endif; ! end of select check if ((mail_recipient = eve$kt_null) or (get_info(mail_recipient,"type") = UNSPECIFIED)) then loc_mail_recipient := read_line( "MAIL "+mess_lines+" from buffer "+loc_buffer_name+" to: "); edit( loc_mail_recipient,trim,collapse,off); IF loc_mail_recipient = eve$x_null then ABORT; ENDIF; else loc_mail_recipient := mail_recipient; endif; IF (get_info(eve$x_mail_foreign,"type") <> unspecified ) then IF ( eve$x_mail_foreign <> eve$x_null ) then loc_mail_recipient := eve_mail_cnv_foreign(loc_mail_recipient); ENDIF; ENDIF; ! IF loc_mail_recipient = eve$x_null then ! ABORT; ! ENDIF; if ((mail_subject = eve$kt_null) or (get_info(mail_subject,"type") = UNSPECIFIED)) then loc_mail_subject := read_line("Subject: "); else loc_mail_subject := mail_subject; endif; if (get_info (eve$x_dcl_process, "type") = unspecified) or (eve$x_dcl_process = 0) then eve_create_mail_process; Endif; ! turn off verify and make sure MAIL is default VMS command send('$ set noverify',eve$x_dcl_process); send('$ mail = "" ! @login_dir:mailit "" "',eve$x_dcl_process); ! produce a message in the DCL buffer showing what was sent position(end_of(eve$dcl_buffer)); copy_text(fao('Sending Mail To: !AS',loc_mail_recipient)); split_line; copy_text(fao('Subject: !AS',loc_mail_subject)); split_line; copy_text(fao('from !AS of buffer !AS at !%T', mess_lines,loc_buffer_name,0)); position(end_of(eve$dcl_buffer)); update(current_window); ! this code does work but is not needed for most users ! uncomment it if necessary. also the ELSE and ENDIF ! if last_line-first_line+1 > 30000 then ! if it's big just dump it to a file ! ! write_file(mail_buffer,"eve_mail.tmp"); ! send("$ mail eve_mail.tmp "+mail_recipient+'/subject="'+mail_subject+'"', ! eve$x_dcl_process); ! send('$ delete eve_mail.tmp;/nolog',eve$x_dcl_process); ! else ! if it's small enough, we'll just send it directly from the buffer position( end_of(eve$dcl_buffer)); move_vertical(-1); send('$ mail sys$input: '+loc_mail_recipient+ '/subject="'+loc_mail_subject+'"',eve$x_dcl_process); update(current_window); position( end_of(eve$dcl_buffer)); update(current_window); send(loc_mail_buffer,eve$x_dcl_process); position( end_of(eve$dcl_buffer)); update(current_window); send_eof(eve$x_dcl_process); ! endif; ! endof size comparison position( end_of(eve$dcl_buffer)); update(current_window); position(save_mark); update(current_window); endProcedure ! from WHAT.TPU - finds the current line number, returns it to caller procedure eve_return_line( this_position) ! What line am I on? local saved_mark, ! marker - current position text_mark, ! marker - after snapping to text this_line_position, ! marker - position at start of this_line total_lines, ! integer - total lines in buffer high_line, ! integer - high line limit for binary search low_line, ! integer - low line limit for binary search low_position, ! marker - beginning of low line this_line, ! integer - line number of current guess eob_flag, ! boolean - true if at eob percent; ! integer - percent of way through buffer on_error [TPU$_CONTROLC]: eve$$restore_position (saved_mark); ! restore free cursor position eve$learn_abort; abort; [OTHERWISE]: eve$$restore_position (saved_mark); endon_error; ! Initialization saved_mark := mark (FREE_CURSOR); position (search (ANCHOR, FORWARD)); ! snap the cursor (move_vertical pads) text_mark := mark (NONE); total_lines := get_info (current_buffer, "record_count"); high_line := total_lines + 1; if text_mark = end_of (current_buffer) then if text_mark = beginning_of (current_buffer) then eve$message (EVE$_BUFEMPTY); position (saved_mark); ! no learn_abort here return (FALSE); else eob_flag := TRUE; low_line := total_lines; low_position := end_of (current_buffer); endif; else low_line := 1; low_position := beginning_of (current_buffer); endif; ! Binary search loop exitif high_line - low_line <= 1; this_line := (high_line + low_line) / 2; position (low_position); move_vertical (this_line - low_line); if mark (FREE_CURSOR) > saved_mark then high_line := this_line; else low_line := this_line; low_position := mark (FREE_CURSOR); if mark (FREE_CURSOR) = saved_mark then high_line := this_line; endif; endif; endloop; eve_return_line := low_line; position (saved_mark); endprocedure ! convert a mail list to include the foreign specifier if enabled procedure eve_mail_cnv_foreign(address_list) local ib, addr_len, work_list, out_list, delim_pos, blank_pos, user_delimiters, foreign_delimiter, user_next ; user_delimiters := ', '; foreign_delimiter := '%'; edit(address_list,trim,compress); if (eve$x_mail_foreign <> 0) and (length(eve$x_mail_foreign) >0 )then addr_len := length(address_list); out_list := ''; work_list := address_list; loop delim_pos := index(work_list,','); blank_pos := index(work_list,' '); if ( blank_pos > 0 ) and ( blank_pos < delim_pos ) then delim_pos := blank_pos; endif; if delim_pos = 0 then user_next := work_list; else user_next := substr(work_list,1 ,delim_pos-1); endif; if index(user_next,foreign_delimiter) = 0 then user_next := eve$x_mail_foreign+foreign_delimiter+ user_next; endif; if out_list = eve$x_null then out_list := user_next; else out_list := out_list + ',' + user_next; endif; exitif delim_pos = 0; work_list := substr(work_list,delim_pos+1,addr_len-delim_pos); addr_len := length(work_list); endloop; eve_mail_cnv_foreign := out_list ; else eve_mail_cnv_foreign := address_list; endif; endprocedure