! ----- ADD_IDENTIFIER.FUN ----- ! ! ----- FUNCTION TO ADD IDENTIFIER TO ALL CLUSTER NODES ----- ! ----- (USED TO MAINTAIN THE CLUSTER-WIDE RIGHTSLIST.DAT FILES ----- ! ----- WHEN YOU ARE NOT USING A CLUSTER-COMMON RIGHTSLIST) ----- ! ! ---------- PASSED: ---------- ! ! ----- ENTERED_USERNAME = Username to create ident for ! ----- (or identifier name if this ! ----- is a non-UIC-based ! ----- identifier) ! ----- OCT_UIC_GROUP = Octal UIC Group value (or 0 to ! ----- add a non-UIC-based identifier) ! ----- OCT_UIC_MEMBER = Octal UIC Member value (or 0 to ! ----- add a non-UIC-based identifier) ! ----- EXIT_IF_UIC_EXISTS = TRUE to exit with a value ! ----- of 999% if UIC-format identifier ! ----- to be added already exists ! ----- (No error returned if identifier already exists) ! ! ---------- RETURNED: ---------- ! ! ----- ADD_IDENTIFIER returns FALSE if successful, otherwise ! ----- TRUE if any error occurred ! ! ----- Last Change 02/09/94 by Brian Lomasky ----- ! FUNCTION WORD ADD_IDENTIFIER(WORD EXIT_IF_UIC_EXISTS) %INCLUDE "NUSER.INC" DECLARE WORD ERR_FLAG ! TRUE IF DONE READING RIGHTS DECLARE WORD FIRST_RECORD_WANTED! TRUE IF FIRST RECORD WANTED DECLARE WORD FOUND_IDENTIFIER ! CODE FOR MATCHING RECORD DECLARE WORD I_O_CHNL ! RIGHTSLIST I/O CHNL TO ACCESS DECLARE LONG NEW_IDENT_VALUE ! NEW IDENTIFIER VALUE EXTERNAL LONG FUNCTION DEC_TO_OCT( & LONG) ! CONVERT DECIMAL TO OCTAL EXTERNAL WORD FUNCTION KGB_IDENT_REC_EXISTS( & WORD) ! SEE IF KGB_IDENTIFIER ID EXIST EXTERNAL WORD FUNCTION READ_RIGHTSLIST(WORD, & WORD) ! READ RIGHTSLIST RECORD EXTERNAL WORD FUNCTION SEARCH_RIGHTSLIST(WORD, WORD, & WORD) ! READ MATCHING RIGHTSLIST REC ADD_IDENTIFIER = TRUE ! ASSUME ERROR STATUS IF DEBUG_MODE THEN PRINT "DEBUG>----- Call ADD_IDENTIFIER" END IF ! ----- ENSURE THAT ENTERED_USERNAME DOES NOT ----- ! ----- ALREADY EXIST ON THE LOCAL NODE ----- ! ----- SEARCH FIRST RIGHTSLIST.DAT FILE BY ITS ----- ! ----- ALTERNATE KEY #2 TO CHECK FOR A VALID IDENTIFIER ----- ! ----- STORE IDENTIFIER TO SEARCH FOR ----- IF DEBUG_MODE THEN PRINT "DEBUG>ADD_IDENTIFIER: SEARCH FOR " + & TRM$(ENTERED_USERNAME) END IF KGB_NAME = ENTERED_USERNAME IF SEARCH_RIGHTSLIST(1%, 2%, FALSE) THEN !IF NOT COPY_USERS_ACCOUNT THEN ! ----- PRINT WARNING IF IDENTIFIER EXISTS ----- ! PRINT "Warning - The " + & ! TRM$(ENTERED_USERNAME) + & ! " identifier already exists" + & ! " on the local node" + BEL !END IF ADD_IDENTIFIER = FALSE ! RETURN SUCCESS STATUS EXIT FUNCTION END IF ! ----- SEE IF THIS IDENTIFIER EXISTS ON ANY OTHER ----- ! ----- NODE'S RIGHTSLIST.DAT FILE ----- IF DEBUG_MODE THEN PRINT "DEBUG>ADD_IDENTIFIER: CHECK OTHER NODES" END IF ! ----- STORE IDENTIFIER TO SEARCH FOR ----- KGB_NAME = ENTERED_USERNAME FOUND_IDENTIFIER = 0% ! INIT FILE I/O CHANNEL I_O_CHNL = 1% ! SET TO SKIP FIRST CHANNEL ! ----- FOR EACH OPEN FILE: ----- WHILE I_O_CHNL < RIGHTSLIST_COUNTER I_O_CHNL = I_O_CHNL + 1% ! ----- SKIP IF RIGHTSLIST IS UNAVAILABLE ----- ITERATE IF TRM$(RIGHTSLIST_SPECS(I_O_CHNL)) = "" IF SEARCH_RIGHTSLIST(I_O_CHNL, 2%, FALSE) THEN ! ----- STORE INDEX OF MATCHING FILE ----- FOUND_IDENTIFIER = I_O_CHNL ! ----- SET TO EXIT LOOP ----- I_O_CHNL = RIGHTSLIST_COUNTER END IF NEXT IF FOUND_IDENTIFIER = 0% THEN ! ----- ADD THIS NEW IDENTIFIER TO ALL ----- ! ----- CLUSTER-WIDE RIGHTSLISTS ----- IF DEBUG_MODE THEN PRINT "DEBUG>ADD_IDENTIFIER: ADD NEW" END IF ! ----- SEE IF ADDING A NON-UIC IDENTIFIER ----- IF OCT_UIC_GROUP = 0% THEN RESTART_ID: IF DEBUG_MODE THEN PRINT "DEBUG>ADD_IDENTIFIER:" + & " LOCATE NXT" END IF ! ----- LOCATE THE LARGEST "NEXT ----- ! ----- AVAILABLE IDENTIFIER VALUE" FROM ----- ! ----- THE MAINTENANCE RECORDS IN THE ----- ! ----- RIGHTSLISTS ----- NEW_IDENT_VALUE = 0% I_O_CHNL = 0% ! ----- FOR EACH OPEN FILE: ----- WHILE I_O_CHNL < RIGHTSLIST_COUNTER I_O_CHNL = I_O_CHNL + 1% ! ----- SKIP IF RIGHTSLIST ----- ! ----- IS UNAVAILABLE ----- IF TRM$(RIGHTSLIST_SPECS(I_O_CHNL)) = "" THEN ITERATE END IF ! ----- SET FOR MAINTENANCE RECORD ----- KGB_IDENTIFIER = 0% ! ----- READ THE MAINTENANCE REC ----- IF SEARCH_RIGHTSLIST( & I_O_CHNL, 0%, FALSE) THEN UNLOCK #I_O_CHNL ! ----- CALC NEW ----- ! ----- IDENTIFIER VALUE ----- IF KGB_NEXT_ID > & NEW_IDENT_VALUE & OR NEW_IDENT_VALUE = 0% THEN NEW_IDENT_VALUE & = KGB_NEXT_ID END IF ELSE ! ----- PRINT ERROR IF ----- ! ----- NO MAINTENANCE REC ----- ! ----- FOUND ----- PRINT "Error -" + & " Maintenance" & + " record" + & " does not" + & " exist on " + & TRM$( & RIGHTSLIST_NODES& (I_O_CHNL)) + BEL EXIT FUNCTION END IF NEXT ! ----- ENSURE THAT THE LARGEST "NEXT ----- ! ----- AVAILABLE IDENTIFIER VALUE" FROM ----- ! ----- THE MAINTENANCE RECORD IS NOT ----- ! ----- USED IN ANY OF THE RIGHTSLISTS ----- IF DEBUG_MODE THEN PRINT "DEBUG>ADD_IDENTIFIER: CHECK NXT" END IF WHILE FOUND_IDENTIFIER = 0% ! ----- STORE KGB_IDENTIFIER KEY ----- KGB_IDENTIFIER = NEW_IDENT_VALUE ! ----- ASSUME NOT FOUND ----- FOUND_IDENTIFIER = 1% I_O_CHNL = 0% ! ----- FOR EACH OPEN FILE: ----- WHILE I_O_CHNL < RIGHTSLIST_COUNTER I_O_CHNL = I_O_CHNL + 1% ! ----- SKIP IF RIGHTSLIST ----- ! ----- IS NOT AVAILABLE ----- IF TRM$(RIGHTSLIST_SPECS& (I_O_CHNL)) = "" THEN ITERATE END IF IF NOT KGB_IDENT_REC_EXISTS(& I_O_CHNL) THEN ITERATE END IF ! ----- SET FLAG IF EXISTS ----- FOUND_IDENTIFIER = 0% UNLOCK #I_O_CHNL ! ----- SET TO EXIT LOOP ----- I_O_CHNL = RIGHTSLIST_COUNTER NEXT ! ----- INCREMENT NEW IDENTIFIER ----- ! ----- IF IT IS ALREADY BEING ----- ! ----- USED ----- IF FOUND_IDENTIFIER = 0% THEN NEW_IDENT_VALUE = & NEW_IDENT_VALUE + 1% END IF NEXT FOUND_IDENTIFIER = 0% ! ----- FOUND AN UNUSED NEXT ----- ! ----- IDENTIFIER VALUE TO BE USED ----- ! ----- UPDATE EACH OF THE ----- ! ----- MAINTENANCE RECORDS ----- IF DEBUG_MODE THEN PRINT "DEBUG>ADD_IDENTIFIER: UPD MAINT" END IF I_O_CHNL = 0% ! ----- FOR EACH OPEN FILE: ----- WHILE I_O_CHNL < RIGHTSLIST_COUNTER I_O_CHNL = I_O_CHNL + 1% ! ----- SKIP IF RIGHTSLIST ----- ! ----- IS UNAVAILABLE ----- IF TRM$(RIGHTSLIST_SPECS(I_O_CHNL)) = "" THEN ITERATE END IF ! ----- SET FOR MAINTENANCE RECORD ----- KGB_IDENTIFIER = 0% ! ----- READ AND LOCK THE ----- ! ----- MAINTENANCE RECORD ----- IF SEARCH_RIGHTSLIST( & I_O_CHNL, 0%, TRUE) THEN ! ----- SANITY CHECK IN ----- ! ----- CASE SOMEONE ELSE ----- ! ----- JUST ADDED AN ----- ! ----- IDENTIFIER ----- IF KGB_NEXT_ID > & NEW_IDENT_VALUE THEN GOTO RESTART_ID END IF ! ----- UPDATE NEXT ----- ! ----- AVAILABLE IDENT ----- KGB_NEXT_ID = & NEW_IDENT_VALUE + 1% UPDATE #I_O_CHNL UNLOCK #I_O_CHNL ELSE ! ----- PRINT ERROR IF NO ----- ! ----- MAINTENANCE RECORD ----- ! ----- FOUND ----- PRINT "Error - Maint" + & "enance record" & + " does not" + & " exist on " + & TRM$( & RIGHTSLIST_NODES& (I_O_CHNL)) + BEL EXIT FUNCTION END IF NEXT ! ----- STORE THE NEW IDENTS ----- IF DEBUG_MODE THEN PRINT "DEBUG>ADD_IDENTIFIER: STORE NEW" END IF I_O_CHNL = 0% ! ----- FOR EACH OPEN FILE: ----- WHILE I_O_CHNL < RIGHTSLIST_COUNTER I_O_CHNL = I_O_CHNL + 1% ! ----- SKIP IF RIGHTSLIST ----- ! ----- IS UNAVAILABLE ----- IF TRM$(RIGHTSLIST_SPECS(I_O_CHNL)) = "" THEN ITERATE END IF ! ----- STORE NEW IDENTIFIER WITH ----- ! ----- RESOURCE ATTRIBUTE ----- KGB_IDENTIFIER = NEW_IDENT_VALUE KGB_ATTRIBUTES = 2% ^ 0% KGB_HOLDER(0%) = 0% KGB_HOLDER(1%) = 0% KGB_NAME = ENTERED_USERNAME PUT #I_O_CHNL, COUNT 48% PRINT "Added new " + & TRM$(ENTERED_USERNAME) & + " identifier to " + & TRM$(RIGHTSLIST_NODES( & I_O_CHNL)) + "..." UNLOCK #I_O_CHNL NEXT ELSE IF DEBUG_MODE THEN PRINT "DEBUG>ADD_IDENTIFIER: NEW UIC" END IF I_O_CHNL = 0% ! ----- FOR EACH OPEN FILE: ----- WHILE I_O_CHNL < RIGHTSLIST_COUNTER I_O_CHNL = I_O_CHNL + 1% ! ----- SKIP IF RIGHTSLIST IS ----- ! ----- UNAVAILABLE ----- ITERATE IF TRM$( & RIGHTSLIST_SPECS(I_O_CHNL)) = "" ! ----- STORE KGB_IDENTIFIER KEY ----- KGB_UIC_GROUP = OCT_UIC_GROUP KGB_UIC_MEMBER = OCT_UIC_MEMBER ! ----- ERROR IF THIS UIC VALUE ----- ! ----- ALREADY EXISTS AS AN ----- ! ----- IDENTIFIER RECORD ON THIS ----- ! ----- NODE ----- IF KGB_IDENT_REC_EXISTS(I_O_CHNL) THEN IF EXIT_IF_UIC_EXISTS THEN UNLOCK #I_O_CHNL ! ----- RETURN ----- ! ----- CODE FOR ----- ! ----- EXISTING ----- ! ----- UIC ----- ADD_IDENTIFIER = 999% EXIT FUNCTION END IF PRINT "Error - [" + & NUM1$(DEC_TO_OCT& ((KGB_UIC_GROUP & ))) & + "," + NUM1$( & DEC_TO_OCT(( & KGB_UIC_MEMBER & ))) + "] UIC" + & " ident value" +& " already" + & " exists on " + & TRM$( & RIGHTSLIST_NODES& (I_O_CHNL)) UNLOCK #I_O_CHNL EXIT FUNCTION END IF ! ----- DO THE ADD ----- KGB_UIC_GROUP = OCT_UIC_GROUP KGB_UIC_MEMBER = OCT_UIC_MEMBER KGB_ATTRIBUTES = 0% KGB_HOLDER(0%) = 0% KGB_HOLDER(1%) = 0% KGB_NAME = ENTERED_USERNAME PUT #I_O_CHNL, COUNT 48% PRINT "Added new " + & TRM$(ENTERED_USERNAME) & + " UIC-format" + & " identifier to " + & TRM$(RIGHTSLIST_NODES( & I_O_CHNL)) + "..." UNLOCK #I_O_CHNL NEXT END IF ELSE IF DEBUG_MODE THEN PRINT "DEBUG>ADD_IDENTIFIER: COPY TO LOCAL NODE" END IF ! ----- STORE THE DATA TO BE COPIED IN A SAFE ----- ! ----- PLACE ----- SEARCH_IDENTIFIER = KGB_IDENTIFIER SEARCH_ATTRIBUTES = KGB_ATTRIBUTES SEARCH_HOLDER(0%) = KGB_HOLDER(0%) SEARCH_HOLDER(1%) = KGB_HOLDER(1%) SEARCH_NAME = KGB_NAME ! ----- ENSURE THAT THE NEW IDENTIFIER DOES NOT ----- ! ----- ALREADY EXIST ON THE LOCAL NODE ----- ! ----- SEARCH FIRST RIGHTSLIST.DAT FILE BY ITS ----- ! ----- ALTERNATE KEY #2 TO CHECK FOR A VALID ----- ! ----- IDENTIFIER ----- IF SEARCH_RIGHTSLIST(1%, 0%, FALSE) THEN ! ----- PRINT ERROR IF IDENTIFIER VALUE ----- ! ----- EXISTS ----- PRINT "Error - Can't copy this" + & " identifier from a remote" + & " node to the local node due to" PRINT " an identifier" + & " value which already" + & " exists on the local node." + BEL ! ----- TRY TO LOCATE THE NAME ----- ! ----- FOR THIS IDENTIFIER VALUE ----- ERR_FLAG = FALSE FIRST_RECORD_WANTED = TRUE WHILE NOT ERR_FLAG IF READ_RIGHTSLIST( & FIRST_RECORD_WANTED, 1%) THEN ERR_FLAG = TRUE ITERATE END IF FIRST_RECORD_WANTED = FALSE ! ----- SEE IF DONE SEARCHING FOR ----- ! ----- THIS IDENTIFIER ----- IF SEARCH_IDENTIFIER <> KGB_IDENTIFIER THEN ERR_FLAG = TRUE ITERATE END IF ! ----- SKIP IF NON-IDENTIFIER ----- ! ----- RECORD ----- ITERATE IF REC_LEN <> 48% PRINT " This identifier" & + " value belongs to " & + TRM$(KGB_NAME) + & " on the local node" + BEL ! ----- SET FLAG TO EXIT LOOP ----- ERR_FLAG = TRUE NEXT UNLOCK #1% ! ----- EXIT WITH ERROR STATUS ----- EXIT FUNCTION END IF ! ----- RESTORE THE VALUES TO BE COPIED ----- KGB_IDENTIFIER = SEARCH_IDENTIFIER KGB_ATTRIBUTES = SEARCH_ATTRIBUTES KGB_HOLDER(0%) = SEARCH_HOLDER(0%) KGB_HOLDER(1%) = SEARCH_HOLDER(1%) KGB_NAME = SEARCH_NAME PUT #1%, COUNT 48% PRINT "Copied new " + & TRM$(ENTERED_USERNAME) + & " identifier to local node..." END IF UNLOCK #1% ADD_IDENTIFIER = FALSE ! RETURN SUCCESS STATUS END FUNCTION