ANU News Patch Patch ID: 930902_newsutility.c!ewilts@galaxy.gov.bc.ca Date: 02-Sep-1993 Author: Ed Wilts ewilts@galaxy.gov.bc.ca News Version: 6.1beta8 News Files: NewsUtility.C Description: Makes three changes to log_to_usage_file(): 1. If secure (/Sys/Exec) logical name News_Usage_Anonymous is defined, then the contents of the UAF Account field is written to News_Usage_Log, instead of the username. 2. If no items have been read or posted, no entry is written. 3. The default extension quantity for News_Usage_Log is increased to 50. *** newsutility.c --- newsutility_rev.c ************** *** 45,47 ** **-- **/ --- 45,55 ----- + ** V6.1 2-SEP-1993 ewilts@galaxy.gov.bc.ca + ** - allow for anonymous logging if NEWS_USAGE_ANONYMOUS is defined + ** /exec in the default table (normally /sys) + ** Logging will be done by ACCOUNT field instead of username + ** V6.1 2-SEP-1993 ewilts@galaxy.gov.bc.ca + ** - don't write out a news_usage_log record for entries with 0 articles read + posted + ** V6.1 2-SEP-1993 ewilts@galaxy.gov.bc.ca + ** - change default extension quantity on news_usage_log to 50. ** **-- **/ ************** *** 3573,3578 static int *group_nums, *read_groups, *post_groups; char *trans; unsigned short len = 0; if (flag == 0) { time(&start_time); max_index = 0; --- 3582,3603 ----- static int *group_nums, *read_groups, *post_groups; char *trans; unsigned short len = 0; + typedef struct _ItemList + { + short buffer_length; + short item_code; + void *buffer_address; + long *return_length_address; + } ItemList; + #include + extern int sys$getuai(); + char account[9]; + int accountlen = 0; + ItemList + getuai_itmlist[] = { + 8,UAI$_ACCOUNT,&account,&accountlen}; + + account[9] = '\0'; if (flag == 0) { time(&start_time); max_index = 0; ************** *** 3609,3614 } } /* if (!no_priv()) return; */ /* Translate logical name. */ if (!(trans = news_getenv("NEWS_USAGE_LOG",1))) return; sysprv(); --- 3634,3640 ----- } } /* if (!no_priv()) return; */ + if ( (read_count + post_count) == 0 ) return; /* Translate logical name. */ if (!(trans = news_getenv("NEWS_USAGE_LOG",1))) return; sysprv(); ************** *** 3614,3620 sysprv(); retry_cnt = 3; do { ! if (!(fpl = fopen(trans,"a","shr=get"))) sleep(1); else break; } while (--retry_cnt >= 0); if (fpl) { time(&end_time); --- 3640,3646 ----- sysprv(); retry_cnt = 3; do { ! if (!(fpl = fopen(trans,"a","shr=get","deq=50"))) sleep(1); else break; } while (--retry_cnt >= 0); if (fpl) { time(&end_time); ************** *** 3619,3625 if (fpl) { time(&end_time); dif_time = (start_time > end_time) ? 0L : end_time - start_time; ! fprintf(fpl,"%s: User %s - %ld minutes - %d articles read - %d posted\n", dat(), usr_username, (dif_time + 30) / 60, read_count, post_count); for (i = 0; i < max_index; i++) { g = ga_locate(group_nums[i]); --- 3645,3658 ----- if (fpl) { time(&end_time); dif_time = (start_time > end_time) ? 0L : end_time - start_time; ! if (news_getenv("NEWS_USAGE_ANONYMOUS",1)) ! { ! sys$getuai(0,0,c$dsc(usr_username),getuai_itmlist,0,0,0,0); ! fprintf(fpl,"%s: Account %8s - %ld minutes - %d articles read - %d posted\n", ! dat(), account, (dif_time + 30) / 60, read_count, post_count); ! } ! else ! fprintf(fpl,"%s: User %s - %ld minutes - %d articles read - %d posted\n", dat(), usr_username, (dif_time + 30) / 60, read_count, post_count); for (i = 0; i < max_index; i++) { g = ga_locate(group_nums[i]); *** patchlist.h;-1 --- patchlist.h ************** *** 1,1 =+=+= End =+=+= --- 1,2 ----- + 930902_newsutility.c!ewilts@galaxy.gov.bc.ca =+=+= End =+=+=