$! ********************************************************************** $! * INSTALL_RESET_NEWMAIL_COUNT.COM * $! * This procedure extracts and builds the following utilities: * $! * * $! * RESET_NEWMAIL_COUNT.EXE - resets the current user's newmail * $! * count to the actual number of "NEW" messages in his * $! * NEWMAIL folder. * $! * RESET_NEWMAIL_COUNT.COM - command procedure to run above image. * $! * RESET_NEWMAIL_ALL_USERS.COM - command procedure to submit * $! * RESET_NEWMAIL_COUNT.COM for every user on the system. * $! * * $! * Invokation: @INSTALL_RESET_NEWMAIL_COUNT * $! * This will create the above two command procedures, create and * $! * compile RESET_NEWMAIL_COUNT.C, and link * $! * RESET_NEWMAIL_COUNT.EXE. The protections on all files are * $! * then changed to W:RE. * $! * * $! * Version: 1.0 * $! * * $! * 28-FEB-1997 RDJ Command Procedure Creation. * $! ********************************************************************** $! $ Call Extract_Files $ Call Compile_Image $ Type SYS$INPUT This procedure has created the following files: RESET_NEWMAIL_COUNT.EXE When executed, sets the current user's newmail count to the actual number of messages in the NEWMAIL folder marked as 'new'. RESET_NEWMAIL_COUNT.COM Command procedure to execute RESET_NEWMAIL_COUNT.EXE. A command procedure interface to the image is necessary for RESET_NEWMAIL_ALL_USERS.COM to work. Users may also execute this procedure directly to reset their own newmail counters at any time. RESET_NEWMAIL_ALL_USERS.COM This procedure SUBMITs RESET_NEWMAIL_COUNT.COM on behalf of every user on the system. The procedure submits the jobs to batch queue TEMPMAIL$BATCH, which it creates and then deletes when all processing has completed. $ Write SYS$OUTPUT "If these procedures are moved from ",F$Environment("Default"),"," $ Type SYS$INPUT you must edit RESET_NEWMAIL_COUNT.COM and RESET_NEWMAIL_ALL_USERS.COM to reflect this change. $ Exit $! $! ********************************************************************** $! * Extract_Files: Extract the two command procedures and the C source * $! * file. * $! ********************************************************************** $ Extract_Files: SubRoutine $ Call Extract_C_File $ Call Extract_Reset_Single $ Call Extract_Reset_All $ Exit $ EndSubRoutine ! Extract_Files $! $! $! ********************************************************************** $! * Compile_Image: Compile RESET_NEWMAIL_COUNT.C. * $! ********************************************************************** $ Compile_Image: SubRoutine $ If F$Search("RESET_NEWMAIL_COUNT.C") .EQS. "" $ Then $ Write SYS$OUTPUT "Unable to locate RESET_NEWMAIL_COUNT.C. Aborting!" $ Exit %x18292 $ EndIf $ Arch_Type = F$GetSyi("Arch_Name") $ If F$Search("SYS$SYSTEM:DECC$COMPILER.EXE") .EQS. "" $ Then $ If Arch_Type .EQS. "VAX" $ Then $ Write SYS$OUTPUT "Compiling with VAXC compiler.." $ CC RESET_NEWMAIL_COUNT.C $ Link/Exec=RESET_NEWMAIL_COUNT.EXE SYS$INPUT/Opt RESET_NEWMAIL_COUNT,SYS$SHARE:VAXCRTL/Share $ Set File/Protection=(G:RE,W:RE) RESET_NEWMAIL_COUNT.EXE $ Else $ Write SYS$OUTPUT "Unable to locate C compiler on this system." $ Exit 2 $ EndIf $ Else $ Write SYS$OUTPUT "Compiling with DECC compiler.." $ CC RESET_NEWMAIL_COUNT.C $ Link RESET_NEWMAIL_COUNT $ Set File/Protection=(G:RE,W:RE) RESET_NEWMAIL_COUNT.EXE $ EndIf $ Exit $ EndSubRoutine ! Compile_Image $! $! $! ********************************************************************** $! * Extract_C_File: Extract RESET_NEWMAIL_COUNT.C * $! ********************************************************************** $ Extract_C_File: SubRoutine $ Write SYS$OUTPUT "Extracting RESET_NEWMAIL_COUNT.C" $ Open/Write OutFile RESET_NEWMAIL_COUNT.C $ WO := Write OutFile $ WO "/************************************************************************" $ WO " * File: RESET_NEWMAIL_COUNT.C *" $ WO " * Author: Richard D. Johnson *" $ WO " * Created: 3-MAR-1994 *" $ WO " * *" $ WO " * Function: This program resets the current user's newmail count to *" $ WO " * the actual number of messages in the NEWMAIL folder *" $ WO " * which are flagged as 'new'. It does NOT search other *" $ WO " * folders for new messages. *" $ WO " ************************************************************************/" $ WO "" $ WO "" $ WO "#include " $ WO "#include " $ WO "#include " $ WO "#ifdef __DECC" $ WO "#include " $ WO "#endif" $ WO "" $ WO "" $ WO "typedef struct itmlst { /* item list for MAIL$ calls */" $ WO " short buffer_length; /* length of input/output buffer*/" $ WO " short item_code; /* item to get/set */" $ WO " void *buffer_address; /* address of buffer */" $ WO " void *return_length_address; /* pointer to length of buffer */" $ WO "} ITMLST;" $ WO "" $ WO "ITMLST nulllist[] = {{0,0,0,0}}; /* empty item list */" $ WO "" $ WO "" $ WO "" $ WO "main () {" $ WO " unsigned long mailfile_context = 0; /* context for open mail file */" $ WO " unsigned long folder_context = 0; /* context for open folder */" $ WO " unsigned long user_context = 0; /* context for user functions */" $ WO " unsigned long status; /* status of service calls */" $ WO " unsigned short new_messages = 0; /* number of new messages */" $ WO " long messages_selected = 0; /* # of msgs in NEWMAIL folder */" $ WO " long j; /* lcv/current message */" $ WO " unsigned short message_flags; /* misc. message flags */" $ WO "" $ WO "#ifdef __DECC" $ WO "#pragma __nostandard" $ WO "#endif" $ WO "ITMLST folder_inlist[] = { /* open new folder */" $ WO " {4,MAIL$_MESSAGE_FILE_CTX,&mailfile_context,0}," $ WO " /* folder context info */" $ WO " {0,MAIL$_NOSIGNAL,0,0}, /* don't signal errors */" $ WO " {0,0,0,0}};" $ WO "ITMLST nosignal[] = { /* generic no signal item list */" $ WO " {0,MAIL$_NOSIGNAL,0,0}, /* don't signal errors */" $ WO " {0,0,0,0}};" $ WO "ITMLST select_inlist[] = { /* select newmail folder */" $ WO " {7,MAIL$_MESSAGE_FOLDER,""NEWMAIL"",0},/* folder name to open */" $ WO " {0,MAIL$_NOSIGNAL,0,0}, /* don't signal errors */" $ WO " {0,0,0,0}};" $ WO "ITMLST select_outlist[] = { /* open folder output */" $ WO " {4,MAIL$_MESSAGE_SELECTED,&messages_selected,0}," $ WO " {0,0,0,0}}; /* # msgs selected */" $ WO "ITMLST info_inlist[] = { /* get message info */" $ WO " {4,MAIL$_MESSAGE_ID,0,0}, /* message to get info on */" $ WO " {0,MAIL$_NOSIGNAL,0,0}, /* don't signal errors */" $ WO " {0,0,0,0}};" $ WO "ITMLST info_outlist[] = { /* get message info output */" $ WO " {2,MAIL$_MESSAGE_RETURN_FLAGS,&message_flags,0}, /* message flags */" $ WO " {0,0,0,0}};" $ WO "ITMLST setcount_inlist[] = { /* set newmail count */" $ WO " {4,MAIL$_USER_CREATE_IF,0,0}, /* create user profile */" $ WO " {2,MAIL$_USER_SET_NEW_MESSAGES,&new_messages,0}, /* set newmail count */" $ WO " {0,0,0,0}};" $ WO "#ifdef __DECC" $ WO "#pragma __standard" $ WO "#endif" $ WO " " $ WO " if ((status = mail$mailfile_begin(&mailfile_context,nosignal,nulllist)) == SS$_NORMAL) {" $ WO " if ((status = mail$mailfile_open(&mailfile_context,nosignal,nulllist)) == SS$_NORMAL) {" $ WO " if ((status = mail$message_begin(&folder_context,folder_inlist,nulllist)) == SS$_NORMAL) {" $ WO " if ((status = mail$message_select(&folder_context,select_inlist,select_outlist)) == SS$_NORMAL) {" $ WO " info_inlist[0].buffer_address = &j;" $ WO " for (j=1; j<=messages_selected; j++) {" $ WO " if ((status = mail$message_info(&folder_context,info_inlist,info_outlist)) == SS$_NORMAL) {" $ WO " if (message_flags & MAIL$M_NEWMSG)" $ WO " new_messages++;" $ WO " }" $ WO " }" $ WO " }" $ WO " mail$message_end(&folder_context,nulllist,nulllist);" $ WO " }" $ WO " mail$mailfile_close(&mailfile_context,nulllist,nulllist);" $ WO " }" $ WO " mail$mailfile_end(&mailfile_context,nulllist,nulllist);" $ WO " }" $ WO " if ((status = mail$user_begin(&user_context,nulllist,nulllist)) == SS$_NORMAL) {" $ WO " printf (""Resetting newmail count to %d...\n"", new_messages);" $ WO " status = mail$user_set_info(&user_context,setcount_inlist,nulllist);" $ WO " mail$user_end(&user_context,nulllist,nulllist);" $ WO " }" $ WO "}" $ WO "" $ Close OutFile $ Set File/Protection=(G:RE,W:RE) RESET_NEWMAIL_COUNT.C $ Exit $ EndSubRoutine ! Extract_C_File $! $! $! ********************************************************************** $! * Extract_Reset_Single: Extract RESET_NEWMAIL_COUNT.COM * $! ********************************************************************** $ Extract_Reset_Single: SubRoutine $ Write SYS$OUTPUT "Extracting RESET_NEWMAIL_COUNT.COM" $ Open/Write OutFile RESET_NEWMAIL_COUNT.COM $ WO := Write OutFile $ WO "$! **********************************************************************" $ WO "$! * RESET_NEWMAIL_COUNT.COM *" $ WO "$! * Resets the current user's newmail counter to the actual number *" $ WO "$! * of messages in his NEWMAIL folder which are marked 'new'. *" $ WO "$! * *" $ WO "$! * 05-FEB-1997 RDJ Command Procedure Creation. *" $ WO "$! **********************************************************************" $ WO "$!" $ WO "$ Write SYS$OUTPUT ""Resetting newmail counter for "",F$GetJPI("""",""UserName"")" $ WO "$ Run ",F$Environment("Default"),"RESET_NEWMAIL_COUNT" $ WO "$!" $ WO "$ Exit" $ Close OutFile $ Set File/Protection=(G:RE,W:RE) RESET_NEWMAIL_COUNT.COM $ Exit $ EndSubRoutine ! Extract_Reset_Single $! $! $! ********************************************************************** $! * Extract_Reset_All: Extract RESET_NEWMAIL_ALL_USERS.COM * $! ********************************************************************** $ Extract_Reset_All: SubRoutine $ Write SYS$OUTPUT "Extracting RESET_NEWMAIL_ALL_USERS.COM" $ Open/Write OutFile RESET_NEWMAIL_ALL_USERS.COM $ WO := Write OutFile $ WO "$! **********************************************************************" $ WO "$! * RESET_NEWMAIL_ALL_USERS.COM *" $ WO "$! * Reset the 'newmail' count for all users on the system. *" $ WO "$! * *" $ WO "$! * This job will submit a batch job for each user on the system to *" $ WO "$! * batch queue MAILTEMP$BATCH which will run SYS$MANAGER: *" $ WO "$! * RESET_NEWMAIL_COUNT.COM. This batch job will reset the user's *" $ WO "$! * newmail counter to the actual number of NEW messages in the *" $ WO "$! * NEWMAIL folder. *" $ WO "$! * *" $ WO "$! * 28-FEB-1997 RDJ Command Procedure Creation. *" $ WO "$! **********************************************************************" $ WO "$ Set NoOn" $ WO "$ If P1 .EQS. ""SUBMITDELETE"" Then Goto Submit_Delete_Job" $ WO "$ If P1 .EQS. ""DELETEQUEUE"" Then Goto Delete_Temp_Queue $ WO "$ Close/NoLog UAF_File" $ WO "$ If F$TrnLnm(""SYSUAF"") .EQS. """"" $ WO "$ Then" $ WO "$ Open/Share/Read/Error=No_UAF_File UAF_File SYS$SYSTEM:SYSUAF.DAT" $ WO "$ Else" $ WO "$ Open/Share/Read/Error=No_UAF_File UAF_File SYSUAF" $ WO "$ EndIf" $ WO "$!" $ WO "$ Initialize/Queue/Batch/Job_Limit=1/Base_Prio=2/Start MAILTEMP$BATCH" $ WO "$ User_Loop:" $ WO "$ Read/Error=No_More_Users UAF_File Line" $ WO "$ Username = F$Edit(F$Extract(4,12,Line),""Trim"")" $ WO "$ Write SYS$OUTPUT ""Submitting job for user ["",Username,""]""" $ WO "$ Submit/Queue=MAILTEMP$BATCH/NoLog/NoNotify/NoPrint/User='Username' -" $ WO " ",F$Environment("Default"),"RESET_NEWMAIL_COUNT/NoID" $ WO "$ Goto User_Loop" $ WO "$ No_More_Users:" $ WO "$ Close UAF_File" $ WO "$ Write SYS$OUTPUT """"" $ WO "$ Submit/NoLog/NoNotify/NoID/Param=(""SUBMITDELETE"",'$Entry')/Queue=MAILTEMP$BATCH -" $ WO " 'F$Environment(""Procedure"")'" $ WO "$ Write SYS$OUTPUT ""Done!""" $ WO "$ Exit" $ WO "$!" $ WO "$ No_UAF_File:" $ WO "$ Write SYS$OUTPUT ""Unable to locate SYSUAF.DAT. Aborting!""" $ WO "$ Exit" $ WO "$!" $ WO "$ Submit_Delete_Job:" $ WO "$ Write SYS$OUTPUT ""Synchronizing to entry "",P2,""...""" $ WO "$ Show Entry/Full 'P2'" $ WO "$ Synchronize/Entry='P2'" $ WO "$ Submit/NoLog/Queue=MAILTEMP$BATCH/NoPrint/NoNotify/Param=""DELETEQUEUE"" -" $ WO " 'F$Environment(""Procedure"")'/NOID" $ WO "$ Exit" $ WO "$!" $ WO "$ Delete_Temp_Queue:" $ WO "$ Stop/Queue/Reset MAILTEMP$BATCH" $ WO "$ Delete/Queue MAILTEMP$BATCH" $ WO "$ Exit" $ Close OutFile $ Set File/Protection=(G:RE,W:RE) RESET_NEWMAIL_ALL_USERS.COM $ Exit $ EndSubRoutine ! Extract_Reset_All