From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 24-MAY-1991 02:54:49.30
To:	ARISIA::EVERHART
CC:	
Subj:	was Problem with VMSMAIL_PROFILE.DATA - now mail_edit 1/4

From:	RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.97)
	 id AA25408; Fri, 24 May 91 02:45:40 EDT
Message-Id:  <9105240645.AA25408@crdgw1.ge.com>
Received: From SCFB.NWC.NAVY.MIL by CRVAX.SRI.COM with TCP; Thu, 23 MAY 91 16:27:43 PDT
Date: 23 May 91 13:02:00 PDT
From: "351M::LEVINE" <levine%351m.decnet@scfb.nwc.navy.mil>
Subject: was Problem with VMSMAIL_PROFILE.DATA - now mail_edit 1/4
To: "info-vax" <info-vax@kl.sri.com>

>Subject: Problem with VMSMAIL_PROFILE.DATA
>We have just discovered that old entries in SYS$SYSTEM:VMSMAIL_PROFILE.DATA are
>not removed during our usercode deletion routine. We discovered it when an old
>usercode was recreated, and MAIL to that account wouldn't work because it
>claimed it had a sub-directory for MAIL which didn't exists (the previous owner
>must have done a SET MAIL_DIRECTORY to seperate mail from SYS$LOGIN).
>
>Is there anyway of "cleaning up" this file so that it only contains entries
>that are actually used?
>
>Cheers
>
>Jason
>
>---
>-------------------------------------------------------------------------------
>Jason Haar. Network Consultant, CSC, University of Canterbury, Christchurch, 
>New Zealand. Email j.haar@csc.canterbury.ac.nz Ph: 64 3 642336 Fax: 64 3 642999
>-------------------------------------------------------------------------------
Jason
	While I did not have that probelm, I did find myself in the need to
clean up my VMSMAIL_PROFILE.DAT not long ago, so useing the callable mail
routines, I wrote the following general purpose editor for user records in that
file. Most fields can be modified. On start up, it cheks to see if users appear
in VMSMAIL_PROFILE.DAT but not in SYSUAF.DAT and flags those names. For more
information see the document. 
	Sent in vms_share format, 4 parts.

Michael N. LeVine  Naval Weapons Center, China Lake, Ca 93555, USA
Internet: levine%fidler.decnet@scfb.nwc.navy.mil,levine%fidler.decnet@26.3.0.85
(619) 939-2614  avn  437-2614 

 "Waiter, there's a bug in my soup!"        
 "No, Sir, it's not a bug, it's a feature!" 
$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.2-007  22-FEB-1990
$!   On 29-MAR-1991 13:45:24.10   By user LEVINE 
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$!+ THIS PACKAGE DISTRIBUTED IN 4 PARTS, TO KEEP EACH PART
$!  BELOW 30 BLOCKS
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. MAIL_PROFILE_EDIT.C;108
$!       2. MAIL_PROFILE_EDIT.DOC;3
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ if .not. f$verify() then $ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
"output_file"));ENDPROCEDURE;Unpacker;QUIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create 'f'
X/*`09`09`09Mail Profile  Data File Management Program
X`09`09`09Michael N. LeVine
X`09`09`09Code 3511
X`09`09`09Naval Weapons Center
X`09`09`09China Lake
X`09`09`09Ca 93555, USA
X`09`09`09Internet: levine%fidler.decnet@scfb.nwc.navy.mil
X`09`09`09(619) 939-2614  avn  437-2614`20
X
X*/
X#include <descrip.h>
X#include <maildef.h>
X#include <signal.h>
X#include <smgdef.h>
X#include <smgmsg.h>
X#include <ssdef.h>
X#include <stdio.h>
X#include <stdlib.h>
X#include <string.h>
X#include <uaidef.h>
X
X#define MAIL$_NOMOREREC 8314792
X#define NAME_SIZE`0914
X#define MAX_LINE_SIZE`0978
X
Xstruct  itmlst
X`7B`09short`09buffer_length;
X`09short`09item_code;
X`09long`09buffer;
X`09long`09return_length;
X`7D;
Xstruct userlist
X`7B`09struct`09userlist`09*next_user;
X`09short`09new_messages;
X`09long`09in_sysuaf;
X`09long`09auto_purge;
X`09long`09cc_prompt;
X`09long`09copy_forward;
X`09long`09copy_reply;
X`09long`09copy_send;
X`09char`09editor`5B255`5D;
X`09char`09forwarding`5B255`5D;
X`09char`09form`5B255`5D;
X`09char`09directory`5B255`5D;
X`09char`09subdirectory`5B255`5D;
X`09char`09personal_name`5B255`5D;
X`09char`09queue`5B255`5D;
X`09char`09username`5B255`5D;
X`09char`09defdev`5B32`5D;
X`09char`09defdir`5B64`5D;
X`7D;
Xstruct s_descripter
X`7B`09short`09length;
X`09short`09type;
X`09long`09address;
X`7D;
Xstruct m_descripter
X`7B`09short`09length;
X`09char`09dtype;
X`09char`09class;
X`09char`09*pointer;
X`09char`09scale;
X`09char`09digits;
X`09char`09aflags;
X`09char`09dimct;
X`09long`09arsize;
X`09char`09*a0;
X`09long`09m1;
X`09long`09l1;
X`09long`09u1;
X`7D;
X#define TRUE`091
X#define`09FALSE`090
X/* static smg vars */
Xlong pasteboard_id,keyboard_id,banner_id;
Xlong last_entry,last_record;
X
X/* static mail stuff */
Xlong context,user_count;
Xstruct userlist *user_list,*end_list,*temp_list;
Xstruct m_descripter menu_list;
X
Xmain(int argc,char **argv)
X`7B`09long i,status,action,first;
X`09void init_smg(),init_user_list(),build_user_menu_array(),close_down();
X`09void process_user(),add_user_list();
X`09long select_uesr_action();
X
X`09init_smg();
X
X`09if(argc==1)
X`09`7B`09init_user_list();
X`09`7D
X`09else
X`09`7B`09first=1;
X`09`09for(i=1;i<argc;++i)
X`09`09`7B`09add_user_list(argv`5Bi`5D,first);
X`09`09`09first=0;
X`09`09`7D
X`09`7D
X
X`09while(1)
X`09`7B`09build_user_menu_array();
X`09`09action=select_user_action();
X`09`09if(action==(user_count+1))
X`09`09`7B`09close_down();
X`09`09`09exit(0);
X`09`09`7D
X`09`09if((action>0)&(action<=user_count))process_user(action);
X`09`09
X`09`09free(menu_list.pointer);
X`09`7D
X`7D
Xvoid init_smg()
X`7B`09long`09status;
X`09struct s_descripter notice;
X
X`09last_entry=last_record=1;
X`09notice.length=strlen("Loading Data");
X`09notice.type=0;
X`09notice.address="Loading Data";
X`09status=smg$create_pasteboard(&pasteboard_id);
X`09if((status&1)==0)exit(status);
X`09status=smg$create_virtual_keyboard(&keyboard_id);
X`09if((status&1)==0)exit(status);
X`09status=smg$create_virtual_display(&24,&80,&banner_id);
X`09if((status&1)==0)exit(status);
X`09status=smg$erase_display(&banner_id);
X`09if((status&1)==0)exit(status);
X`09status=smg$put_chars(&banner_id,&notice,&12,&34);
X`09if((status&1)==0)exit(status);
X`09status=smg$paste_virtual_display(&banner_id,&pasteboard_id,&1,&1);
X`09if((status&1)==0)exit(status);
X`7D
Xvoid init_user_list()
X`7B`09struct itmlst item_list_in`5B2`5D,item_list_out`5B15`5D;
X`09struct itmlst uai_lst`5B3`5D,null_list;
X`09struct s_descripter user_name;
X`09long status;
X
X`09user_list=end_list=NULL;
X`09user_count=0;
X
X`09memset(item_list_out,0,15*sizeof(struct itmlst));
X`09memset(item_list_in,0,2*sizeof(struct itmlst));
X`09memset(uai_lst,0,3*sizeof(struct itmlst));
X`09memset(&null_list,0,sizeof(struct itmlst));
X
X`09context=0;
X`09status=mail$user_begin(&context,item_list_in,item_list_out);
X`09if(status!=SS$_NORMAL)
X`09`7B`09perror("mail profile open error");
X`09`09exit(status);
X`09`7D
X
X`09item_list_in`5B0`5D.item_code=MAIL$_USER_FIRST;
X`09item_list_out`5B0`5D.item_code=MAIL$_USER_AUTO_PURGE;
X`09item_list_out`5B0`5D.buffer_length=4;
X`09item_list_out`5B1`5D.item_code=MAIL$_USER_CC_PROMPT;
X`09item_list_out`5B1`5D.buffer_length=4;
X`09item_list_out`5B2`5D.item_code=MAIL$_USER_COPY_FORWARD;
X`09item_list_out`5B2`5D.buffer_length=4;
X`09item_list_out`5B3`5D.item_code=MAIL$_USER_COPY_REPLY;
X`09item_list_out`5B3`5D.buffer_length=4;
X`09item_list_out`5B4`5D.item_code=MAIL$_USER_COPY_SEND;
X`09item_list_out`5B4`5D.buffer_length=4;
X`09item_list_out`5B5`5D.item_code=MAIL$_USER_EDITOR;
X`09item_list_out`5B5`5D.buffer_length=255;
X`09item_list_out`5B6`5D.item_code=MAIL$_USER_FORWARDING;
X`09item_list_out`5B6`5D.buffer_length=255;
X`09item_list_out`5B7`5D.item_code=MAIL$_USER_FORM;
X`09item_list_out`5B7`5D.buffer_length=255;
X`09item_list_out`5B8`5D.item_code=MAIL$_USER_FULL_DIRECTORY;
X`09item_list_out`5B8`5D.buffer_length=255;
X`09item_list_out`5B9`5D.item_code=MAIL$_USER_NEW_MESSAGES;
X`09item_list_out`5B9`5D.buffer_length=2;
X`09item_list_out`5B10`5D.item_code=MAIL$_USER_PERSONAL_NAME;
X`09item_list_out`5B10`5D.buffer_length=255;
X`09item_list_out`5B11`5D.item_code=MAIL$_USER_QUEUE;
X`09item_list_out`5B11`5D.buffer_length=255;
X`09item_list_out`5B12`5D.item_code=MAIL$_USER_RETURN_USERNAME;
X`09item_list_out`5B12`5D.buffer_length=255;
X`09item_list_out`5B13`5D.item_code=MAIL$_USER_SUB_DIRECTORY;
X`09item_list_out`5B13`5D.buffer_length=255;
X`09uai_lst`5B0`5D.item_code=UAI$_DEFDEV;
X`09uai_lst`5B0`5D.buffer_length=32;
X`09uai_lst`5B1`5D.item_code=UAI$_DEFDIR;
X`09uai_lst`5B1`5D.buffer_length=64;
X
X`09while(1)
X`09`7B`09temp_list=malloc(sizeof(struct userlist));
X`09`09if(temp_list==NULL)
X`09`09`7B`09perror("allocation error");
X`09`09`09exit(1);
X`09`09`7D
X`09`09item_list_out`5B0`5D.buffer= &temp_list->auto_purge;
X`09`09item_list_out`5B1`5D.buffer= &temp_list->cc_prompt;
X`09`09item_list_out`5B2`5D.buffer= &temp_list->copy_forward;
X`09`09item_list_out`5B3`5D.buffer= &temp_list->copy_reply;
X`09`09item_list_out`5B4`5D.buffer= &temp_list->copy_send;
X`09`09item_list_out`5B5`5D.buffer= &temp_list->editor;
X`09`09item_list_out`5B6`5D.buffer= &temp_list->forwarding;
X`09`09item_list_out`5B7`5D.buffer= &temp_list->form;
X`09`09item_list_out`5B8`5D.buffer= &temp_list->directory;
X`09`09item_list_out`5B9`5D.buffer= &temp_list->new_messages;
X`09`09item_list_out`5B10`5D.buffer= &temp_list->personal_name;
X`09`09item_list_out`5B11`5D.buffer= &temp_list->queue;
X`09`09item_list_out`5B12`5D.buffer= &temp_list->username;
X`09`09item_list_out`5B13`5D.buffer= &temp_list->subdirectory;
X`09`09memset(temp_list,0,sizeof(struct userlist));
X`09`09status=mail$user_get_info(&context,
X`09`09`09&item_list_in,&item_list_out);
X`09`09if(status!=SS$_NORMAL)
X`09`09`7B`09if(status==MAIL$_NOMOREREC)
X`09`09`09`7B`09free(temp_list);
X`09`09`09`09break;
X`09`09`09`7D
X`09`09`09perror("get user error");
X`09`09`09exit(status);
X`09`09`7D
X`09`09user_count++;
X`09`09item_list_in`5B0`5D.item_code=MAIL$_USER_NEXT;
X`09`09uai_lst`5B0`5D.buffer= &temp_list->defdev;
X`09`09uai_lst`5B1`5D.buffer= &temp_list->defdir;
X`09`09user_name.type=0;
X`09`09user_name.address= &temp_list->username;
X`09`09user_name.length=strlen(temp_list->username);
X`09`09if(user_name.length>12)user_name.length=12;
X`09`09status=smg$put_chars(&banner_id,&user_name,&22,&1,
X`09`09`09&SMG$M_ERASE_LINE);
X`09`09if((status&1)==0)exit(status);
X`09`09status=sys$getuai(0,0,&user_name,uai_lst,0,0,0);
X`09`09if(status!=SS$_NORMAL)
X`09`09`7B`09temp_list->in_sysuaf=FALSE;`7D
X`09`09else
X`09`09`7B`09temp_list->in_sysuaf=TRUE;`7D
X`09`09if(user_list==NULL)
X`09`09`7B`09user_list=end_list=temp_list;`7D
X`09`09else
X`09`09`7B`09end_list->next_user=temp_list;
X`09`09`09end_list=temp_list;
X`09`09`7D
X`09`7D
X`7D
Xvoid add_user_list(char *specific,long first)
X`7B`09struct itmlst item_list_in`5B2`5D,item_list_out`5B15`5D;
X`09struct itmlst uai_lst`5B3`5D,null_list;
X`09struct s_descripter user_name;
X`09long status;
X
X`09memset(item_list_out,0,15*sizeof(struct itmlst));
X`09memset(item_list_in,0,2*sizeof(struct itmlst));
X`09memset(uai_lst,0,3*sizeof(struct itmlst));
X`09memset(&null_list,0,sizeof(struct itmlst));
X
X`09if(first!=0)
X`09`7B`09user_list=end_list=NULL;
X`09`09user_count=0;
X`09`09context=0;
X`09`09status=mail$user_begin(&context,item_list_in,item_list_out);
X`09`09if(status!=SS$_NORMAL)
X`09`09`7B`09perror("mail profile open error");
X`09`09`09exit(status);
X`09`09`7D
X`09`7D
X`09item_list_in`5B0`5D.item_code=MAIL$_USER_USERNAME;
X`09item_list_in`5B0`5D.buffer=specific;
X`09item_list_in`5B0`5D.buffer_length=strlen(item_list_in`5B0`5D.buffer);
X`09item_list_out`5B0`5D.item_code=MAIL$_USER_AUTO_PURGE;
X`09item_list_out`5B0`5D.buffer_length=4;
X`09item_list_out`5B1`5D.item_code=MAIL$_USER_CC_PROMPT;
X`09item_list_out`5B1`5D.buffer_length=4;
X`09item_list_out`5B2`5D.item_code=MAIL$_USER_COPY_FORWARD;
X`09item_list_out`5B2`5D.buffer_length=4;
X`09item_list_out`5B3`5D.item_code=MAIL$_USER_COPY_REPLY;
X`09item_list_out`5B3`5D.buffer_length=4;
X`09item_list_out`5B4`5D.item_code=MAIL$_USER_COPY_SEND;
X`09item_list_out`5B4`5D.buffer_length=4;
X`09item_list_out`5B5`5D.item_code=MAIL$_USER_EDITOR;
X`09item_list_out`5B5`5D.buffer_length=255;
X`09item_list_out`5B6`5D.item_code=MAIL$_USER_FORWARDING;
X`09item_list_out`5B6`5D.buffer_length=255;
X`09item_list_out`5B7`5D.item_code=MAIL$_USER_FORM;
X`09item_list_out`5B7`5D.buffer_length=255;
X`09item_list_out`5B8`5D.item_code=MAIL$_USER_FULL_DIRECTORY;
X`09item_list_out`5B8`5D.buffer_length=255;
X`09item_list_out`5B9`5D.item_code=MAIL$_USER_NEW_MESSAGES;
X`09item_list_out`5B9`5D.buffer_length=2;
X`09item_list_out`5B10`5D.item_code=MAIL$_USER_PERSONAL_NAME;
X`09item_list_out`5B10`5D.buffer_length=255;
X`09item_list_out`5B11`5D.item_code=MAIL$_USER_QUEUE;
X`09item_list_out`5B11`5D.buffer_length=255;
X`09item_list_out`5B12`5D.item_code=MAIL$_USER_RETURN_USERNAME;
X`09item_list_out`5B12`5D.buffer_length=255;
X`09item_list_out`5B13`5D.item_code=MAIL$_USER_SUB_DIRECTORY;
X`09item_list_out`5B13`5D.buffer_length=255;
X`09uai_lst`5B0`5D.item_code=UAI$_DEFDEV;
X`09uai_lst`5B0`5D.buffer_length=32;
X`09uai_lst`5B1`5D.item_code=UAI$_DEFDIR;
X`09uai_lst`5B1`5D.buffer_length=64;
X
X`09temp_list=malloc(sizeof(struct userlist));
X`09if(temp_list==NULL)
X`09`7B`09perror("allocation error");
X`09`09exit(1);
X`09`7D
X`09item_list_out`5B0`5D.buffer= &temp_list->auto_purge;
X`09item_list_out`5B1`5D.buffer= &temp_list->cc_prompt;
X`09item_list_out`5B2`5D.buffer= &temp_list->copy_forward;
X`09item_list_out`5B3`5D.buffer= &temp_list->copy_reply;
X`09item_list_out`5B4`5D.buffer= &temp_list->copy_send;
X`09item_list_out`5B5`5D.buffer= &temp_list->editor;
X`09item_list_out`5B6`5D.buffer= &temp_list->forwarding;
X`09item_list_out`5B7`5D.buffer= &temp_list->form;
X`09item_list_out`5B8`5D.buffer= &temp_list->directory;
X`09item_list_out`5B9`5D.buffer= &temp_list->new_messages;
X`09item_list_out`5B10`5D.buffer= &temp_list->personal_name;
X`09item_list_out`5B11`5D.buffer= &temp_list->queue;
X`09item_list_out`5B12`5D.buffer= &temp_list->username;
X`09item_list_out`5B13`5D.buffer= &temp_list->subdirectory;
X`09memset(temp_list,0,sizeof(struct userlist));
X`09status=mail$user_get_info(&context,
X`09`09&item_list_in,&item_list_out);
X`09if(status!=SS$_NORMAL)
X`09`7B`09if(status==MAIL$_NOMOREREC)
X`09`09`7B`09free(temp_list);
X`09`09`09return;
X`09`09`7D
X`09`09perror("get user error");
X`09`09exit(status);
X`09`7D
X`09user_count++;
X`09user_name.type=0;
X`09user_name.address= &temp_list->username;
X`09user_name.length=strlen(temp_list->username);
+-+-+-+-+-+-+-+-  END  OF PART 1 +-+-+-+-+-+-+-+-


