home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / os / vms / 17946 < prev    next >
Encoding:
Internet Message Format  |  1992-11-14  |  14.5 KB

  1. 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
  2. From: LAURI@DCD00.FNAL.GOV (Laurelin of Middle Earth, x2214)
  3. Newsgroups: comp.os.vms
  4. Subject: SETPQL  6/9
  5. Message-ID: <921113111548.20800159@fndcd.fnal.gov>
  6. Date: 13 Nov 92 17:15:48 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Distribution: world
  9. Organization: The Internet
  10. Lines: 440
  11.  
  12. -+-+-+-+-+-+-+-+ START OF PART 6 -+-+-+-+-+-+-+-+
  13. X ******************************************************************/
  14. X
  15. Xvoid test_and_set(long *pval1, long *pval2, short uai_itmcode)
  16. X`7B
  17. X
  18. X if ( zero_is_infinite(uai_itmcode) )`09`09`09`09/* does a 0 value actually
  19. V imply infinite for this parameter? */
  20. X `7B
  21. X`09if ( *pval1 == 0 )`09`09`09`09`09/* then if already at 0, leave it there.
  22. V */
  23. X`09 return;
  24. X
  25. X`09if ( *pval2 == 0 )`09`09`09`09`09/* or, if our other choice is 0, take it
  26. V! */
  27. X`09`7B
  28. X`09  *pval1 = *pval2;
  29. X`09  return;
  30. X`09`7D
  31. X `7D
  32. X if ( *pval1 < *pval2 )`09`09`09`09`09`09/* Ok, the 0 option is over -- now
  33. V just a straight comparison. */
  34. X  *pval1 = *pval2;
  35. X
  36. X return;
  37. X`7D`20
  38. X`0C
  39. X
  40. X/****************************************************
  41. X * this function will return TRUE or FALSE          *
  42. X * depending on whether or not a zero in this field *
  43. X * implies infinite quota.                          *
  44. X ****************************************************/
  45. X
  46. Xshort zero_is_infinite(short uai_itmcode)
  47. X`7B
  48. X switch(uai_itmcode)
  49. X `7B
  50. X`09case UAI$_CPUTIM:
  51. X`09case UAI$_MAXACCTJOBS:
  52. X`09case UAI$_MAXDETACH:
  53. X`09case UAI$_MAXJOBS:
  54. X`09case UAI$_PBYTLM:
  55. X`09case UAI$_SHRFILLM:
  56. X`09`7B
  57. X`09`09return(TRUE);
  58. X`09`7D
  59. X`09default:
  60. X`09`7B
  61. X`09`09return(FALSE);
  62. X`09`7D
  63. X `7D
  64. X`7D
  65. X`0C
  66. X
  67. X/*************************************************************
  68. X * Figure out which datatype is the element we are currently *
  69. X * examining, and cast that datatype into long form.         *
  70. X *************************************************************/
  71. X
  72. Xvoid cast_to_long(union Addr *PAddr, short i, long *lvalue)
  73. X`7B
  74. X if ( Info`5Bi`5D.buflen == WORD )
  75. X   *lvalue = (long) *PAddr->pword.ptr`5Bi`5D;
  76. X else if ( Info`5Bi`5D.buflen == LONG )
  77. X   *lvalue = (long) *PAddr->plong.ptr`5Bi`5D;
  78. X else if ( Info`5Bi`5D.buflen == BYTE )
  79. X   *lvalue = (long) *PAddr->pbyte.ptr`5Bi`5D;
  80. X`7D
  81. X`0C
  82. X
  83. X/*************************************************************
  84. X * Figure out which datatype is the element we are currently *
  85. X * examining, and pull this datatype from a long form.       *
  86. X *************************************************************/
  87. X
  88. Xvoid cast_from_long(union Addr *PAddr, short i, long *lvalue)
  89. X`7B
  90. X if ( Info`5Bi`5D.buflen == WORD )
  91. X   *PAddr->pword.ptr`5Bi`5D = (short) *lvalue;
  92. X else if ( Info`5Bi`5D.buflen == LONG )
  93. X   *PAddr->plong.ptr`5Bi`5D = (long) *lvalue;
  94. X else if ( Info`5Bi`5D.buflen == BYTE )
  95. X   *PAddr->pbyte.ptr`5Bi`5D = (char) *lvalue;
  96. X`7D
  97. X`0C
  98. X
  99. X/*****************************************************
  100. X * Take a longword cputime value and convert it      *
  101. X * into a null-terminated string for the purposes of *
  102. X * giving error messages.                            *
  103. X *****************************************************/
  104. X
  105. Xchar *cvtim(unsigned long cputim)
  106. X`7B
  107. X char timestring`5B17`5D;`09`09`09/* dddd-hh:mm:ss.cc plus null terminator *
  108. V/
  109. X long status;
  110. X long dummy = 0;
  111. X unsigned long quadword`5B2`5D;
  112. X
  113. X status = lib$emul( &time_conversion, &cputim, &dummy, &quadword );
  114. X SIGNAL(status);
  115. X
  116. X status = sys$numtim( &timbuf, &quadword );
  117. X SIGNAL(status);
  118. X
  119. X if ( quadword`5B0`5D == 0  && quadword `5B1`5D == 0 )`09`09/* if return tim
  120. Ve is 0 ( 17-NOV-1858 00:00:00.00 ), convert days to 0 */
  121. X`09timbuf.day = 0;
  122. X`20
  123. X sprintf(timestring, "%0d-%02d:%02d:%02d.%02d", timbuf.day, timbuf.hour, tim
  124. Vbuf.minute, timbuf.second, timbuf.hundredth);
  125. X
  126. X return(timestring);
  127. X`7D
  128. X`0C
  129. X
  130. X/***********************************************
  131. X * function to convert a string to upper case. *
  132. X ***********************************************/
  133. X
  134. Xchar *upcase(char *pc)
  135. X`7B
  136. X`09char *pcopy = pc;
  137. X
  138. X`09while ((*pc = toupper(*pc)) != '\0')
  139. X`09`09pc++;
  140. X`09return(pcopy);
  141. X`7D
  142. X`0C
  143. X
  144. X/***********************************************************************
  145. X * routine to trim any trailing whitespace in a null-terminated string.*
  146. X * returns the address of the first character in the string.           *
  147. X ***********************************************************************/
  148. X
  149. Xchar *strtrim(char *pc)
  150. X`7B
  151. X char *pcopy = pc;
  152. X
  153. X pc = pc + strlen(pc);
  154. X while ( pc-- >= 0 )
  155. X `7B
  156. X    if ( !isspace(*pc) )
  157. X      break;
  158. X `7D
  159. X
  160. X *(pc+1) = '\0';
  161. X return(pcopy);
  162. X`7D
  163. X`0C
  164. X/*********************************************************************
  165. X * Remove any trailing comments from a string of text.               *
  166. X * Comments are defined as anything following an exclamation point.  *
  167. X * We are not being very sophisticated -- no quotation mark checks!! *
  168. X *********************************************************************/
  169. X
  170. Xchar *uncomment(char *pc)
  171. X`7B
  172. X char *pcopy = pc;
  173. X
  174. X *(pc + strcspn(pc,"!")) = '\0';
  175. X return(pcopy);
  176. X`7D
  177. X`20
  178. X`0C
  179. X/*****************************************************
  180. X * Replace multiple spaces/tabs with a single comma. *
  181. X *****************************************************/
  182. X
  183. Xchar *comma_tize(char *pc)
  184. X`7B
  185. X char *pcopy = pc;
  186. X char *iptr;
  187. X char comma`5B`5D = ",";
  188. X short in_space;
  189. X
  190. X in_space = 0;
  191. X iptr = pc;
  192. X
  193. X while( *pc != '\0' )
  194. X `7B
  195. X     if ( isspace(*pc) )
  196. X     `7B
  197. X`09if ( !in_space )
  198. X`09`7B
  199. X`09   in_space = 1;
  200. X`09   *iptr++ = comma`5B0`5D;
  201. X`09`7D
  202. X     `7D
  203. X     else
  204. X     `7B
  205. X`09in_space = 0;
  206. X`09*iptr++ = *pc;
  207. X     `7D
  208. X     pc++;
  209. X `7D
  210. X *iptr = '\0';
  211. X return(pcopy);
  212. X`7D
  213. X`20
  214. X`0C
  215. X
  216. X/*******************************************************
  217. X * Function to display the values stored in the Value  *
  218. X * structures directly (rather than indirectly via the *
  219. X * address pointers.  THIS ROUTINE IS NO LONGER USED,  *
  220. X * but I leave it here for future debugging value.     *
  221. X *******************************************************/
  222. X
  223. Xvoid DISPLAY_value(struct ValueStruct *PValue)
  224. X`7B
  225. X
  226. X printf("\nnow into DISPLAY_value");
  227. X printf("\n\tusername = %s",`09PValue->username);
  228. X printf("\n\tuic = %d",`09`09PValue->uic);
  229. X printf("\n\tastlm = %d",`09PValue->astlm);
  230. X printf("\n\tbiolm = %d",`09PValue->biolm);
  231. X printf("\n\tbytlm = %d",`09PValue->bytlm);
  232. X printf("\n\tcputim = %d",`09PValue->cputim);
  233. X printf("\n\tdfwscnt = %d",`09PValue->dfwscnt);
  234. X printf("\n\tdiolm = %d",`09PValue->diolm);
  235. X printf("\n\tenqlm = %d",`09PValue->enqlm);
  236. X printf("\n\tfillm = %d",`09PValue->fillm);
  237. X printf("\n\tjtquota = %d",`09PValue->jtquota);
  238. X printf("\n\tmaxacctjobs = %d",`09PValue->maxacctjobs);
  239. X printf("\n\tmaxdetach = %d",`09PValue->maxdetach);
  240. X printf("\n\tmaxjobs = %d",`09PValue->maxjobs);
  241. X printf("\n\tpbytlm = %d",`09PValue->pbytlm);
  242. X printf("\n\tpgflquota = %d",`09PValue->pgflquota);
  243. X printf("\n\tprccnt = %d",`09PValue->prccnt);
  244. X printf("\n\tpri = %d",`09`09PValue->pri);
  245. X printf("\n\tquepri = %d",`09PValue->quepri);
  246. X printf("\n\tshrfillm = %d",`09PValue->shrfillm);
  247. X printf("\n\ttqcnt = %d",`09PValue->tqcnt);
  248. X printf("\n\twsextent = %d",`09PValue->wsextent);
  249. X printf("\n\twsquota = %d",`09PValue->wsquota);
  250. X`7D
  251. X`0C
  252. X
  253. X/******************************************************
  254. X * Function to display the PQL values via indirection,*
  255. X * that is, via the Address structures.  This is used *
  256. X * when the /DEBUG qualifier has been entered on the  *
  257. X * command line.                                      *
  258. X ******************************************************/
  259. X
  260. Xvoid DISPLAY_by_addr(union Addr *PAddress)
  261. X`7B
  262. X int i;
  263. X
  264. X printf("\n\tusername = %s",PAddress->plong.pusername);
  265. X
  266. X for ( i = 0; i < MAX_PARAMS; i++ )
  267. X `7B
  268. X   if ( Info`5Bi`5D.shallwe )
  269. X   `7B
  270. X`09if ( Info`5Bi`5D.buflen == WORD )
  271. X`09 printf("\n\titem #%2d, WORD, %s = %d",i, Info`5Bi`5D.text, *PAddress->pw
  272. Vord.ptr`5Bi`5D);
  273. X`09if ( Info`5Bi`5D.buflen == LONG )
  274. X`09 printf("\n\titem #%2d, LONG, %s = %d",i, Info`5Bi`5D.text, *PAddress->pl
  275. Vong.ptr`5Bi`5D);
  276. X`09if ( Info`5Bi`5D.buflen == BYTE )
  277. X`09 printf("\n\titem #%2d, BYTE, %s = %d",i, Info`5Bi`5D.text, *PAddress->pb
  278. Vyte.ptr`5Bi`5D);
  279. X   `7D
  280. X `7D
  281. X`7D
  282. X`0C
  283. X/***************************************************************
  284. X * Function to display the text elements within a linked list. *
  285. X * Used for debugging purposes.                                *
  286. X ***************************************************************/
  287. X
  288. Xvoid DISPLAY_linked_list(char *type, struct LinkedListStruct *PRoot)
  289. X`7B
  290. X struct LinkedListStruct *PCur;
  291. X short i;
  292. X
  293. X printf("\n\nDisplaying values in linked list of type %s",type);
  294. X if ( PRoot == NULL )
  295. X   printf("\t--> list is EMPTY");
  296. X else
  297. X `7B
  298. X   i = 0;
  299. X   for( (PCur  = PRoot);
  300. X        (PCur != NULL);
  301. X        (PCur  = PCur->pfwd) )
  302. X      printf("\n\telement #%d = >%s<, length = %d", i++, PCur->item, PCur->l
  303. Ven);
  304. X `7D
  305. X
  306. X return;
  307. X`7D
  308. X`0C
  309. X
  310. X/************************************************************
  311. X * Function to insert an element of type char into a linked *
  312. X * list.                                                    *
  313. X ************************************************************/
  314. X
  315. Xlong link_into_list( struct LinkedListStruct **PRoot,
  316. X`09`09`09struct LinkedListStruct **PCur,`20
  317. X`09`09`09struct LinkedListStruct **PPrev,`20
  318. X`09`09`09char *string, short len )
  319. X`7B
  320. X if ( len == 0 )
  321. X   return(SS$_NORMAL);`09`09`09`09`09`09/* don't insert empty elements into
  322. V the list. */
  323. X
  324. X *PCur = malloc( sizeof(struct LinkedListStruct) );`09`09/* allocate memory
  325. V for the current structure */
  326. X if ( *PCur == NULL )`09`09`09`09`09`09/* oops, failure, abort captain! */
  327. X   exit(pql_insdynmem);
  328. X
  329. X if ( *PRoot == NULL )`09`09`09`09`09`09/* 1st time through only: */
  330. X `7B
  331. X`09*PRoot = *PCur;`09`09`09`09`09`09/*  -- set the root pointer to the first
  332. V element */
  333. X`09(*PCur)->pbwd = NULL;`09`09`09`09`09/*  -- and set the first element's ba
  334. Vckward pointer to null */
  335. X `7D
  336. X else`09`09`09`09`09`09`09`09/* All other times through: */
  337. X `7B
  338. X`09(*PCur)->pbwd  = *PPrev;`09`09`09`09/*  -- set backward pointer for this
  339. V entry */
  340. X`09(*PCur)->pfwd  = NULL;`09`09`09`09`09/*  -- and forward pointer for this
  341. V entry */
  342. X`09(*PPrev)->pfwd = *PCur;`09`09`09`09`09/*  -- and forward pointer for prev
  343. Vious entry */
  344. X `7D
  345. X *PPrev = *PCur;`09`09`09`09`09`09/* And set up for next time through the lo
  346. Vop */
  347. X
  348. X (*PCur)->len  = len;`09`09`09`09`09`09/* Now get ready to fill the data its
  349. Velf */
  350. X (*PCur)->item = malloc( (*PCur)->len + 1 );`09`09`09/* Allocate memory for
  351. V the string (we just stored the length) */
  352. X if ( (*PCur)->item == NULL )
  353. X   exit(pql_insdynmem);`09`09`09`09`09`09/* oops, abort.*/
  354. X
  355. X strcpy( (*PCur)->item, string );`09`09`09`09/* And copy the string into our
  356. V memory location. */
  357. X
  358. X return(SS$_NORMAL);
  359. X`7D
  360. X
  361. X`0C
  362. X
  363. X/*************************************************************
  364. X * Function to determine if a particular string is contained *
  365. X * in one of the text fields of a linked list.  This is a    *
  366. X * WILDCARD match!!                                          *
  367. X *************************************************************/
  368. X
  369. Xshort in_linked_list(char *string, struct LinkedListStruct *PRoot)
  370. X`7B
  371. X extern long STR$MATCH_WILD();
  372. X long   status;
  373. X struct LinkedListStruct *PCur;
  374. X static char candidate`5BNAM$C_MAXRSS + 1`5D;
  375. X static char pattern`5BNAM$C_MAXRSS + 1`5D;
  376. X static $DESCRIPTOR(candidate_d, candidate);
  377. X static $DESCRIPTOR(pattern_d, pattern);
  378. X
  379. X for ( (PCur  = PRoot);`09`09`09`09`09`09/* loop through all elements in the
  380. V linked list -- unless */
  381. X       (PCur != NULL);`09`09`09`09`09`09/*   we find a match, then exit earl
  382. Vy. */
  383. X       (PCur  = PCur->pfwd) )
  384. X `7B
  385. X`09strcpy(candidate, string);`09`09`09`09/* set up the string descriptors fo
  386. Vr the candidate string */
  387. X`09candidate_d.dsc$w_length = strlen(candidate);
  388. X
  389. X`09strcpy(pattern, PCur->item);`09`09`09`09/* and for the wildcard pattern w
  390. Ve're checking */
  391. X`09pattern_d.dsc$w_length = strlen(pattern);
  392. X
  393. X`09status = STR$MATCH_WILD( &candidate_d, &pattern_d );`09/* let VMS handle
  394. V this for us -- return TRUE if we match. */
  395. X`09if ( status == STR$_MATCH )
  396. X`09  return(TRUE);
  397. X `7D`09`09`09`09`09`09`09`09/* otherwise keep looping. */
  398. X return(FALSE);`09`09`09`09`09`09`09/* no match through entire list -- retur
  399. Vn FALSE. */
  400. X`7D
  401. X`0C
  402. X/***************************************************************
  403. X * Open the exclude file.  If not successful, return a FALSE   *
  404. X * status.  Otherwise, read the records in the exclude file    *
  405. X * and convert them into elements in the ExcludeUser linked    *
  406. X * list.                                                       *
  407. X * Each line may contain more than one entry, either separated *
  408. X * by spaces or commas.  Comments are allowed.                 *
  409. X ***************************************************************/
  410. X
  411. Xlong open_and_read_exclude_file()
  412. X`7B
  413. X extern long STR$ELEMENT();`09`09`09`09/* get next element in a comma-separa
  414. Vted list. */
  415. X long sts;`09`09`09`09`09`09/* RMS status returns. */
  416. X char excfilename`5BNAM$C_MAXRSS + 1`5D;`09`09`09/* store the filename retur
  417. Vned by RMS open */
  418. X char excfilenexp`5BNAM$C_MAXRSS + 1`5D;`09`09`09/*  needs two locations. */
  419. X
  420. X char exc_record`5BNAM$C_MAXRSS + 1`5D;`09`09`09/* the record that we read.
  421. V */
  422. X $DESCRIPTOR(exc_record_d, exc_record);`09`09`09/* needs a descriptor */
  423. X char exc_element`5BNAM$C_MAXRSS + 1`5D;`09`09`09/* we must break it up, it
  424. V might contain multiple entries. */
  425. X $DESCRIPTOR(exc_element_d, exc_element);`09`09/* needs a descriptor */
  426. X char grp_element`5BNAM$C_MAXRSS + 1`5D;`09`09`09/* comma separated list, bu
  427. Vt `5BG023_C,*`5D should be ONE ENTRY!! */
  428. X $DESCRIPTOR(grp_element_d, grp_element);
  429. X long element;`09`09`09`09`09`09/* keep track of which entry. */
  430. X $DESCRIPTOR(comma_d, ",");`09`09`09`09/* descriptor for our list delimiter
  431. V */
  432. X char bracket`5B`5D = "`5B";`09`09`09`09`09/* Brackets on group codes. */
  433. X
  434. X excfab = cc$rms_fab;`09`09`09`09`09/* set up structures for RMS file access
  435. V of the exclude file. */
  436. X excfab.fab$l_fna = &exclude_file;`09`09`09/* filename is that passed on com
  437. Vmand line */
  438. X excfab.fab$b_fns = strlen(exclude_file);
  439. X excfab.fab$l_dna = &DFLT_EXCLUDE_FILE1;`09`09/* or defaults to use for the
  440. V first try.. */
  441. X excfab.fab$b_dns = strlen(DFLT_EXCLUDE_FILE1);
  442. X excfab.fab$b_fac = FAB$M_GET;`09`09`09`09/* readonly access */
  443. X excfab.fab$b_shr = FAB$M_SHRGET `7C `09`09`09/* shared access */
  444. X`09`09    FAB$M_SHRDEL `7C`20
  445. X`09`09    FAB$M_SHRUPD;
  446. X excfab.fab$l_fop = FAB$M_NAM;`09`09`09`09/* associate this with the name bl
  447. Vock */
  448. X excfab.fab$l_nam = &excnam;
  449. X
  450. +-+-+-+-+-+-+-+-  END  OF PART 6 +-+-+-+-+-+-+-+-
  451.  
  452.