home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sdd.hp.com!cs.utexas.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!DCD00.FNAL.GOV!LAURI
- From: LAURI@DCD00.FNAL.GOV (Laurelin of Middle Earth, x2214)
- Newsgroups: comp.os.vms
- Subject: SETPQL 6/9
- Message-ID: <921113111548.20800159@fndcd.fnal.gov>
- Date: 13 Nov 92 17:15:48 GMT
- Sender: daemon@ucbvax.BERKELEY.EDU
- Distribution: world
- Organization: The Internet
- Lines: 440
-
- -+-+-+-+-+-+-+-+ START OF PART 6 -+-+-+-+-+-+-+-+
- X ******************************************************************/
- X
- Xvoid test_and_set(long *pval1, long *pval2, short uai_itmcode)
- X`7B
- X
- X if ( zero_is_infinite(uai_itmcode) )`09`09`09`09/* does a 0 value actually
- V imply infinite for this parameter? */
- X `7B
- X`09if ( *pval1 == 0 )`09`09`09`09`09/* then if already at 0, leave it there.
- V */
- X`09 return;
- X
- X`09if ( *pval2 == 0 )`09`09`09`09`09/* or, if our other choice is 0, take it
- V! */
- X`09`7B
- X`09 *pval1 = *pval2;
- X`09 return;
- X`09`7D
- X `7D
- X if ( *pval1 < *pval2 )`09`09`09`09`09`09/* Ok, the 0 option is over -- now
- V just a straight comparison. */
- X *pval1 = *pval2;
- X
- X return;
- X`7D`20
- X`0C
- X
- X/****************************************************
- X * this function will return TRUE or FALSE *
- X * depending on whether or not a zero in this field *
- X * implies infinite quota. *
- X ****************************************************/
- X
- Xshort zero_is_infinite(short uai_itmcode)
- X`7B
- X switch(uai_itmcode)
- X `7B
- X`09case UAI$_CPUTIM:
- X`09case UAI$_MAXACCTJOBS:
- X`09case UAI$_MAXDETACH:
- X`09case UAI$_MAXJOBS:
- X`09case UAI$_PBYTLM:
- X`09case UAI$_SHRFILLM:
- X`09`7B
- X`09`09return(TRUE);
- X`09`7D
- X`09default:
- X`09`7B
- X`09`09return(FALSE);
- X`09`7D
- X `7D
- X`7D
- X`0C
- X
- X/*************************************************************
- X * Figure out which datatype is the element we are currently *
- X * examining, and cast that datatype into long form. *
- X *************************************************************/
- X
- Xvoid cast_to_long(union Addr *PAddr, short i, long *lvalue)
- X`7B
- X if ( Info`5Bi`5D.buflen == WORD )
- X *lvalue = (long) *PAddr->pword.ptr`5Bi`5D;
- X else if ( Info`5Bi`5D.buflen == LONG )
- X *lvalue = (long) *PAddr->plong.ptr`5Bi`5D;
- X else if ( Info`5Bi`5D.buflen == BYTE )
- X *lvalue = (long) *PAddr->pbyte.ptr`5Bi`5D;
- X`7D
- X`0C
- X
- X/*************************************************************
- X * Figure out which datatype is the element we are currently *
- X * examining, and pull this datatype from a long form. *
- X *************************************************************/
- X
- Xvoid cast_from_long(union Addr *PAddr, short i, long *lvalue)
- X`7B
- X if ( Info`5Bi`5D.buflen == WORD )
- X *PAddr->pword.ptr`5Bi`5D = (short) *lvalue;
- X else if ( Info`5Bi`5D.buflen == LONG )
- X *PAddr->plong.ptr`5Bi`5D = (long) *lvalue;
- X else if ( Info`5Bi`5D.buflen == BYTE )
- X *PAddr->pbyte.ptr`5Bi`5D = (char) *lvalue;
- X`7D
- X`0C
- X
- X/*****************************************************
- X * Take a longword cputime value and convert it *
- X * into a null-terminated string for the purposes of *
- X * giving error messages. *
- X *****************************************************/
- X
- Xchar *cvtim(unsigned long cputim)
- X`7B
- X char timestring`5B17`5D;`09`09`09/* dddd-hh:mm:ss.cc plus null terminator *
- V/
- X long status;
- X long dummy = 0;
- X unsigned long quadword`5B2`5D;
- X
- X status = lib$emul( &time_conversion, &cputim, &dummy, &quadword );
- X SIGNAL(status);
- X
- X status = sys$numtim( &timbuf, &quadword );
- X SIGNAL(status);
- X
- X if ( quadword`5B0`5D == 0 && quadword `5B1`5D == 0 )`09`09/* if return tim
- Ve is 0 ( 17-NOV-1858 00:00:00.00 ), convert days to 0 */
- X`09timbuf.day = 0;
- X`20
- X sprintf(timestring, "%0d-%02d:%02d:%02d.%02d", timbuf.day, timbuf.hour, tim
- Vbuf.minute, timbuf.second, timbuf.hundredth);
- X
- X return(timestring);
- X`7D
- X`0C
- X
- X/***********************************************
- X * function to convert a string to upper case. *
- X ***********************************************/
- X
- Xchar *upcase(char *pc)
- X`7B
- X`09char *pcopy = pc;
- X
- X`09while ((*pc = toupper(*pc)) != '\0')
- X`09`09pc++;
- X`09return(pcopy);
- X`7D
- X`0C
- X
- X/***********************************************************************
- X * routine to trim any trailing whitespace in a null-terminated string.*
- X * returns the address of the first character in the string. *
- X ***********************************************************************/
- X
- Xchar *strtrim(char *pc)
- X`7B
- X char *pcopy = pc;
- X
- X pc = pc + strlen(pc);
- X while ( pc-- >= 0 )
- X `7B
- X if ( !isspace(*pc) )
- X break;
- X `7D
- X
- X *(pc+1) = '\0';
- X return(pcopy);
- X`7D
- X`0C
- X/*********************************************************************
- X * Remove any trailing comments from a string of text. *
- X * Comments are defined as anything following an exclamation point. *
- X * We are not being very sophisticated -- no quotation mark checks!! *
- X *********************************************************************/
- X
- Xchar *uncomment(char *pc)
- X`7B
- X char *pcopy = pc;
- X
- X *(pc + strcspn(pc,"!")) = '\0';
- X return(pcopy);
- X`7D
- X`20
- X`0C
- X/*****************************************************
- X * Replace multiple spaces/tabs with a single comma. *
- X *****************************************************/
- X
- Xchar *comma_tize(char *pc)
- X`7B
- X char *pcopy = pc;
- X char *iptr;
- X char comma`5B`5D = ",";
- X short in_space;
- X
- X in_space = 0;
- X iptr = pc;
- X
- X while( *pc != '\0' )
- X `7B
- X if ( isspace(*pc) )
- X `7B
- X`09if ( !in_space )
- X`09`7B
- X`09 in_space = 1;
- X`09 *iptr++ = comma`5B0`5D;
- X`09`7D
- X `7D
- X else
- X `7B
- X`09in_space = 0;
- X`09*iptr++ = *pc;
- X `7D
- X pc++;
- X `7D
- X *iptr = '\0';
- X return(pcopy);
- X`7D
- X`20
- X`0C
- X
- X/*******************************************************
- X * Function to display the values stored in the Value *
- X * structures directly (rather than indirectly via the *
- X * address pointers. THIS ROUTINE IS NO LONGER USED, *
- X * but I leave it here for future debugging value. *
- X *******************************************************/
- X
- Xvoid DISPLAY_value(struct ValueStruct *PValue)
- X`7B
- X
- X printf("\nnow into DISPLAY_value");
- X printf("\n\tusername = %s",`09PValue->username);
- X printf("\n\tuic = %d",`09`09PValue->uic);
- X printf("\n\tastlm = %d",`09PValue->astlm);
- X printf("\n\tbiolm = %d",`09PValue->biolm);
- X printf("\n\tbytlm = %d",`09PValue->bytlm);
- X printf("\n\tcputim = %d",`09PValue->cputim);
- X printf("\n\tdfwscnt = %d",`09PValue->dfwscnt);
- X printf("\n\tdiolm = %d",`09PValue->diolm);
- X printf("\n\tenqlm = %d",`09PValue->enqlm);
- X printf("\n\tfillm = %d",`09PValue->fillm);
- X printf("\n\tjtquota = %d",`09PValue->jtquota);
- X printf("\n\tmaxacctjobs = %d",`09PValue->maxacctjobs);
- X printf("\n\tmaxdetach = %d",`09PValue->maxdetach);
- X printf("\n\tmaxjobs = %d",`09PValue->maxjobs);
- X printf("\n\tpbytlm = %d",`09PValue->pbytlm);
- X printf("\n\tpgflquota = %d",`09PValue->pgflquota);
- X printf("\n\tprccnt = %d",`09PValue->prccnt);
- X printf("\n\tpri = %d",`09`09PValue->pri);
- X printf("\n\tquepri = %d",`09PValue->quepri);
- X printf("\n\tshrfillm = %d",`09PValue->shrfillm);
- X printf("\n\ttqcnt = %d",`09PValue->tqcnt);
- X printf("\n\twsextent = %d",`09PValue->wsextent);
- X printf("\n\twsquota = %d",`09PValue->wsquota);
- X`7D
- X`0C
- X
- X/******************************************************
- X * Function to display the PQL values via indirection,*
- X * that is, via the Address structures. This is used *
- X * when the /DEBUG qualifier has been entered on the *
- X * command line. *
- X ******************************************************/
- X
- Xvoid DISPLAY_by_addr(union Addr *PAddress)
- X`7B
- X int i;
- X
- X printf("\n\tusername = %s",PAddress->plong.pusername);
- X
- X for ( i = 0; i < MAX_PARAMS; i++ )
- X `7B
- X if ( Info`5Bi`5D.shallwe )
- X `7B
- X`09if ( Info`5Bi`5D.buflen == WORD )
- X`09 printf("\n\titem #%2d, WORD, %s = %d",i, Info`5Bi`5D.text, *PAddress->pw
- Vord.ptr`5Bi`5D);
- X`09if ( Info`5Bi`5D.buflen == LONG )
- X`09 printf("\n\titem #%2d, LONG, %s = %d",i, Info`5Bi`5D.text, *PAddress->pl
- Vong.ptr`5Bi`5D);
- X`09if ( Info`5Bi`5D.buflen == BYTE )
- X`09 printf("\n\titem #%2d, BYTE, %s = %d",i, Info`5Bi`5D.text, *PAddress->pb
- Vyte.ptr`5Bi`5D);
- X `7D
- X `7D
- X`7D
- X`0C
- X/***************************************************************
- X * Function to display the text elements within a linked list. *
- X * Used for debugging purposes. *
- X ***************************************************************/
- X
- Xvoid DISPLAY_linked_list(char *type, struct LinkedListStruct *PRoot)
- X`7B
- X struct LinkedListStruct *PCur;
- X short i;
- X
- X printf("\n\nDisplaying values in linked list of type %s",type);
- X if ( PRoot == NULL )
- X printf("\t--> list is EMPTY");
- X else
- X `7B
- X i = 0;
- X for( (PCur = PRoot);
- X (PCur != NULL);
- X (PCur = PCur->pfwd) )
- X printf("\n\telement #%d = >%s<, length = %d", i++, PCur->item, PCur->l
- Ven);
- X `7D
- X
- X return;
- X`7D
- X`0C
- X
- X/************************************************************
- X * Function to insert an element of type char into a linked *
- X * list. *
- X ************************************************************/
- X
- Xlong link_into_list( struct LinkedListStruct **PRoot,
- X`09`09`09struct LinkedListStruct **PCur,`20
- X`09`09`09struct LinkedListStruct **PPrev,`20
- X`09`09`09char *string, short len )
- X`7B
- X if ( len == 0 )
- X return(SS$_NORMAL);`09`09`09`09`09`09/* don't insert empty elements into
- V the list. */
- X
- X *PCur = malloc( sizeof(struct LinkedListStruct) );`09`09/* allocate memory
- V for the current structure */
- X if ( *PCur == NULL )`09`09`09`09`09`09/* oops, failure, abort captain! */
- X exit(pql_insdynmem);
- X
- X if ( *PRoot == NULL )`09`09`09`09`09`09/* 1st time through only: */
- X `7B
- X`09*PRoot = *PCur;`09`09`09`09`09`09/* -- set the root pointer to the first
- V element */
- X`09(*PCur)->pbwd = NULL;`09`09`09`09`09/* -- and set the first element's ba
- Vckward pointer to null */
- X `7D
- X else`09`09`09`09`09`09`09`09/* All other times through: */
- X `7B
- X`09(*PCur)->pbwd = *PPrev;`09`09`09`09/* -- set backward pointer for this
- V entry */
- X`09(*PCur)->pfwd = NULL;`09`09`09`09`09/* -- and forward pointer for this
- V entry */
- X`09(*PPrev)->pfwd = *PCur;`09`09`09`09`09/* -- and forward pointer for prev
- Vious entry */
- X `7D
- X *PPrev = *PCur;`09`09`09`09`09`09/* And set up for next time through the lo
- Vop */
- X
- X (*PCur)->len = len;`09`09`09`09`09`09/* Now get ready to fill the data its
- Velf */
- X (*PCur)->item = malloc( (*PCur)->len + 1 );`09`09`09/* Allocate memory for
- V the string (we just stored the length) */
- X if ( (*PCur)->item == NULL )
- X exit(pql_insdynmem);`09`09`09`09`09`09/* oops, abort.*/
- X
- X strcpy( (*PCur)->item, string );`09`09`09`09/* And copy the string into our
- V memory location. */
- X
- X return(SS$_NORMAL);
- X`7D
- X
- X`0C
- X
- X/*************************************************************
- X * Function to determine if a particular string is contained *
- X * in one of the text fields of a linked list. This is a *
- X * WILDCARD match!! *
- X *************************************************************/
- X
- Xshort in_linked_list(char *string, struct LinkedListStruct *PRoot)
- X`7B
- X extern long STR$MATCH_WILD();
- X long status;
- X struct LinkedListStruct *PCur;
- X static char candidate`5BNAM$C_MAXRSS + 1`5D;
- X static char pattern`5BNAM$C_MAXRSS + 1`5D;
- X static $DESCRIPTOR(candidate_d, candidate);
- X static $DESCRIPTOR(pattern_d, pattern);
- X
- X for ( (PCur = PRoot);`09`09`09`09`09`09/* loop through all elements in the
- V linked list -- unless */
- X (PCur != NULL);`09`09`09`09`09`09/* we find a match, then exit earl
- Vy. */
- X (PCur = PCur->pfwd) )
- X `7B
- X`09strcpy(candidate, string);`09`09`09`09/* set up the string descriptors fo
- Vr the candidate string */
- X`09candidate_d.dsc$w_length = strlen(candidate);
- X
- X`09strcpy(pattern, PCur->item);`09`09`09`09/* and for the wildcard pattern w
- Ve're checking */
- X`09pattern_d.dsc$w_length = strlen(pattern);
- X
- X`09status = STR$MATCH_WILD( &candidate_d, &pattern_d );`09/* let VMS handle
- V this for us -- return TRUE if we match. */
- X`09if ( status == STR$_MATCH )
- X`09 return(TRUE);
- X `7D`09`09`09`09`09`09`09`09/* otherwise keep looping. */
- X return(FALSE);`09`09`09`09`09`09`09/* no match through entire list -- retur
- Vn FALSE. */
- X`7D
- X`0C
- X/***************************************************************
- X * Open the exclude file. If not successful, return a FALSE *
- X * status. Otherwise, read the records in the exclude file *
- X * and convert them into elements in the ExcludeUser linked *
- X * list. *
- X * Each line may contain more than one entry, either separated *
- X * by spaces or commas. Comments are allowed. *
- X ***************************************************************/
- X
- Xlong open_and_read_exclude_file()
- X`7B
- X extern long STR$ELEMENT();`09`09`09`09/* get next element in a comma-separa
- Vted list. */
- X long sts;`09`09`09`09`09`09/* RMS status returns. */
- X char excfilename`5BNAM$C_MAXRSS + 1`5D;`09`09`09/* store the filename retur
- Vned by RMS open */
- X char excfilenexp`5BNAM$C_MAXRSS + 1`5D;`09`09`09/* needs two locations. */
- X
- X char exc_record`5BNAM$C_MAXRSS + 1`5D;`09`09`09/* the record that we read.
- V */
- X $DESCRIPTOR(exc_record_d, exc_record);`09`09`09/* needs a descriptor */
- X char exc_element`5BNAM$C_MAXRSS + 1`5D;`09`09`09/* we must break it up, it
- V might contain multiple entries. */
- X $DESCRIPTOR(exc_element_d, exc_element);`09`09/* needs a descriptor */
- X char grp_element`5BNAM$C_MAXRSS + 1`5D;`09`09`09/* comma separated list, bu
- Vt `5BG023_C,*`5D should be ONE ENTRY!! */
- X $DESCRIPTOR(grp_element_d, grp_element);
- X long element;`09`09`09`09`09`09/* keep track of which entry. */
- X $DESCRIPTOR(comma_d, ",");`09`09`09`09/* descriptor for our list delimiter
- V */
- X char bracket`5B`5D = "`5B";`09`09`09`09`09/* Brackets on group codes. */
- X
- X excfab = cc$rms_fab;`09`09`09`09`09/* set up structures for RMS file access
- V of the exclude file. */
- X excfab.fab$l_fna = &exclude_file;`09`09`09/* filename is that passed on com
- Vmand line */
- X excfab.fab$b_fns = strlen(exclude_file);
- X excfab.fab$l_dna = &DFLT_EXCLUDE_FILE1;`09`09/* or defaults to use for the
- V first try.. */
- X excfab.fab$b_dns = strlen(DFLT_EXCLUDE_FILE1);
- X excfab.fab$b_fac = FAB$M_GET;`09`09`09`09/* readonly access */
- X excfab.fab$b_shr = FAB$M_SHRGET `7C `09`09`09/* shared access */
- X`09`09 FAB$M_SHRDEL `7C`20
- X`09`09 FAB$M_SHRUPD;
- X excfab.fab$l_fop = FAB$M_NAM;`09`09`09`09/* associate this with the name bl
- Vock */
- X excfab.fab$l_nam = &excnam;
- X
- +-+-+-+-+-+-+-+- END OF PART 6 +-+-+-+-+-+-+-+-
-
-