This is more-or-less c version of the uustat command procedure that came with DECUS uucp. There are two parts. Use and enjoy! -------------------------------------------------------------------------------- John Roman +1 314 537-7044 M/S GG3I jrroma@bb1t.monsanto.com Monsanto Company Chesterfield, MO 63198 $! ------------------ CUT HERE ----------------------- $ v='f$verify(f$trnlnm("SHARE_VERIFY"))' $! $! This archive created by VMS_SHARE Version 7.2-007 22-FEB-1990 $! On 26-FEB-1991 15:30:06.35 By user JRROMA $! $! This VMS_SHARE Written by: $! Andy Harper, Kings College London UK $! $! Acknowledgements to: $! James Gray - Original VMS_SHARE $! Michael Bednarek - Original Concept and implementation $! $!+ THIS PACKAGE DISTRIBUTED IN 2 PARTS, TO KEEP EACH PART $! BELOW 30 BLOCKS $! $! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER $! AND EXECUTE AS A COMMAND PROCEDURE ( @name ) $! $! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING: $! 1. UUSTAT.C;52 $! $set="set" $set symbol/scope=(nolocal,noglobal) $f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID")) $e="write sys$error ""%UNPACK"", " $w="write sys$output ""%UNPACK"", " $ if f$trnlnm("SHARE_LOG") then $ w = "!" $ ve=f$getsyi("version") $ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START $ e "-E-OLDVER, Must run at least VMS 4.4" $ v=f$verify(v) $ exit 44 $UNPACK: SUBROUTINE ! P1=filename, P2=checksum $ if f$search(P1) .eqs. "" then $ goto file_absent $ e "-W-EXISTS, File ''P1' exists. Skipped." $ delete 'f'* $ exit $file_absent: $ if f$parse(P1) .nes. "" then $ goto dirok $ dn=f$parse(P1,,,"DIRECTORY") $ w "-I-CREDIR, Creating directory ''dn'." $ create/dir 'dn' $ if $status then $ goto dirok $ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped." $ delete 'f'* $ exit $dirok: $ w "-I-PROCESS, Processing file ''P1'." $ if .not. f$verify() then $ define/user sys$output nl: $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1' PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET( SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:= CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b)); LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION( BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1); IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE; MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1; ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")= 1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF"; POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r); ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1; COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE, "output_file"));ENDPROCEDURE;Unpacker;QUIT; $ delete/nolog 'f'* $ CHECKSUM 'P1' $ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT $ e "-E-CHKSMFAIL, Checksum of ''P1' failed." $ ENDSUBROUTINE $START: $ create 'f' X/* X* uustat.c -- a status program for DECUS uucp. X* X* John Roman +1 314 537-7044 X* M/S GG3F jrroma@bb1t.monsanto.com X* Monsanto Company X* Chesterfield, MO 63198 X*`20 X* This program is a program-ized version of the uustat command procedure t Vhat X* comes with DECUS uucp. However, rather than do a directory of the files X* in uucp_spool, this program the does the equivalent of mailq.for. X* mailq.for was posted several weeks ago and is by Jay Whitney and Innovat Vive X* Software. X* X*`09`09THIS CODE IS YOURS -- DO ANYTHING YOU WANT WITH IT. X* X* I would appreciate hearing from you if you improve it in any way. X*/ X#include stdio X#include string X#include descrip X#include ssdef X#include prvdef X#include rms X#include stdlib X#include ctype X#include jpidef X#include lnmdef X#include syidef X#include processes X#include time X#include errno X X/* This is what statedef.h would have in it if it existed. */ X X#define SCH$C_COLPG`091 X#define`09SCH$C_MWAIT`092 X#define`09SCH$C_CEF`093 X#define`09SCH$C_PFW`094 X#define`09SCH$C_LEF`095 X#define`09SCH$C_LEFO`096 X#define`09SCH$C_HIB`097 X#define`09SCH$C_HIBO`098 X#define`09SCH$C_SUSP`099 X#define`09SCH$C_SUSPO`0910 X#define`09SCH$C_FPG`0911 X#define`09SCH$C_COM`0912 X#define`09SCH$C_COMO`0913 X#define`09SCH$C_CUR`0914 X Xtypedef struct `7B X`09short len; X`09short code; X`09int`09addr; X`09int`09len_addr; X`7D ss_list; X Xmain() X`7B X FILE *status_file; X int`09 seed_pid = -1; X int`09 pid; X int`09 master_pid; X int`09 cputime; X int`09 buff_io; X int`09 dir_io; X int`09 state; X int`09 jobtype; X int`09 header = FALSE; X unsigned int login_time`5B2`5D; X unsigned int uptime`5B2`5D; X unsigned int now_now`5B2`5D; X short timlen; X short pid_len; X short cputime_len; X short proc_cnt_len; X short buff_io_len; X short dir_io_len; X short state_len; X short proc_name_len; X short logval_len; X char proc_name`5B16`5D; X char logval`5B256`5D; X char line`5B128`5D; X char state_txt`5B6`5D; X char cpu_string`5B17`5D; X char uptime_string`5B24`5D; X char jobtype_string`5B32`5D; X char date_time`5B24`5D; X X int`09 status; X int`09 i; X int`09 privmask`5B2`5D = `7BPRV$M_SYSPRV `7C PRV$M_WORLD, 0`7D; X X $DESCRIPTOR(systbl, "LNM$SYSTEM"); X $DESCRIPTOR(status_desc, "UUCP_STATUS_uucp"); X $DESCRIPTOR(host_desc, "UUCP_HOST_NAME"); X $DESCRIPTOR(date_time_desc, date_time); X $DESCRIPTOR(uptime_desc, uptime_string); X X ss_list`09itmlst`5B15`5D; X ss_list`09trnlst`5B2`5D; X X X status = sys$setprv(1, privmask, 0, 0); `20 X if (status != SS$_NORMAL) `7B X`09printf("uustat - unable to set sysprv.\n"); X`09exit(1); X `7D X X i = 0; X trnlst`5Bi`5D.len = 255; X trnlst`5Bi`5D.code = LNM$_STRING; X trnlst`5Bi`5D.addr = &logval; X trnlst`5Bi`5D.len_addr = &logval_len; X i++; X trnlst`5Bi`5D.len = 0; X trnlst`5Bi`5D.code = 0; X X i = 0; X itmlst`5Bi`5D.len = 4; X itmlst`5Bi`5D.code = JPI$_PID; X itmlst`5Bi`5D.addr = &pid; X itmlst`5Bi`5D.len_addr = &pid_len; X i++; X itmlst`5Bi`5D.len = 4; X itmlst`5Bi`5D.code = JPI$_CPUTIM; X itmlst`5Bi`5D.addr = &cputime; X itmlst`5Bi`5D.len_addr = &cputime_len; X i++; X itmlst`5Bi`5D.len = 4; X itmlst`5Bi`5D.code = JPI$_BUFIO; X itmlst`5Bi`5D.addr = &buff_io; X itmlst`5Bi`5D.len_addr = &buff_io_len; X i++; X itmlst`5Bi`5D.len = 4; X itmlst`5Bi`5D.code = JPI$_DIRIO; X itmlst`5Bi`5D.addr = &dir_io; X itmlst`5Bi`5D.len_addr = &dir_io_len; X i++; X itmlst`5Bi`5D.len = 4; X itmlst`5Bi`5D.code = JPI$_STATE; X itmlst`5Bi`5D.addr = &state; X itmlst`5Bi`5D.len_addr = &state_len; X i++; X itmlst`5Bi`5D.len = 15; X itmlst`5Bi`5D.code = JPI$_PRCNAM; X itmlst`5Bi`5D.addr = &proc_name; X itmlst`5Bi`5D.len_addr = &proc_name_len; X i++; X itmlst`5Bi`5D.len = 4; X itmlst`5Bi`5D.code = JPI$_JOBTYPE; X itmlst`5Bi`5D.addr = &jobtype; X itmlst`5Bi`5D.len_addr = 0; X i++; X itmlst`5Bi`5D.len = 4; X itmlst`5Bi`5D.code = JPI$_MASTER_PID; X itmlst`5Bi`5D.addr = &master_pid; X itmlst`5Bi`5D.len_addr = 0; X i++; X itmlst`5Bi`5D.len = 8;`09`09`09 X itmlst`5Bi`5D.code = JPI$_LOGINTIM;`09 X itmlst`5Bi`5D.addr = &login_time;`09 X itmlst`5Bi`5D.len_addr = 0; X i++; X itmlst`5Bi`5D.len = 0; X itmlst`5Bi`5D.code = 0; X X status = sys$trnlnm(NULL, &systbl, &host_desc, NULL, &trnlst); X if (status != SS$_NORMAL) `7B X`09printf("Error translating host logical.\n"); X`09printf("\\%s\\\n", strerror(EVMSERR, status)); X`09exit(status); X `7D X logval`5Blogval_len`5D = '\0'; X sys$asctim(&timlen, &date_time_desc, NULL, NULL); X date_time`5Btimlen`5D = '\0'; X while ( (status = sys$getjpiw(NULL, &seed_pid, NULL, &itmlst, NULL,`20 X`09`09NULL, NULL)) != SS$_NOMOREPROC) `7B X`09if(status == SS$_SUSPENDED) continue; X`09if (status != SS$_NORMAL) `7B X`09`09printf("Error with getjpi.\n"); X`09`09printf("\\%s\\\n", strerror(EVMSERR, status)); X`09`09exit(status); /* Probably not have WORLD */ X`09`7D X`09proc_name`5Bproc_name_len`5D = 0; X`09if (!strncmp(proc_name, "uucp", 4) `7C`7C !strncmp(proc_name, "uxqt", 4)) V `7B X`09 if (!header) `7B X`09`09sys$gettim(&now_now); X`09`09lib$sub_times(&now_now, &login_time, &uptime); X`09`09sys$asctim(&timlen, &uptime_desc, &uptime, NULL); X`09`09uptime_string`5Btimlen`5D = '\0'; X`09`09printf("Status of UUCP node %s on %s Uptime %s\n",`20 X`09`09`09`09logval, date_time, uptime_string); X`09`09printf( X"Process Pid State CPU BuffIO DirIO Typ Ve\n"); X`09 header = TRUE; X`09 `7D X`09 get_state(state, &state_txt); X`09 get_jobtype(jobtype, &jobtype_string); X`09 if (master_pid != pid) strcpy(jobtype_string, "Subproc"); X`09 get_cpu_string(cputime, &cpu_string); X`09 printf("%-15s %X %6s %16.16s %10d %10d %s\n",`20 X`09`09proc_name, pid, state_txt, cpu_string, buff_io, dir_io,`20 X`09`09jobtype_string); X`09`7D X `7D X status = sys$trnlnm(NULL, &systbl, &status_desc, NULL, &trnlst); X X if (status == SS$_NORMAL) `7B X`09logval`5Blogval_len`5D ='\0'; X`09printf("\nStatus logical:\n"); X`09printf("%s", logval); X `7D X X status_file = fopen("uucp_log:stst.wupost", "r", "shr=put,upd,del,get") V; X if (status_file == NULL) `7B X`09printf("Error opening status file.\n"); X`09printf("\\%s\\\n", strerror(errno, 0)); X`09exit(1); X `7D X X printf("Status file:\n"); X while (fgets(line, 128, status_file) != NULL)`20 X`09printf("%s\n", line); X fclose(status_file); X X mailq(); X X remails(); X`7D Xget_jobtype(jobtype, jobtype_string) Xint`09jobtype; Xchar`09*jobtype_string; X`7B X char *string; X X switch (jobtype) `7B X case (JPI$K_DETACHED): X`09string = "Detached"; X`09break; X case (JPI$K_NETWORK): X`09string = "Network"; X`09break; X case (JPI$K_BATCH): X`09string = "Batch"; X`09break; X case (JPI$K_LOCAL): X`09string = "Local"; X`09break; X case (JPI$K_DIALUP): X`09string = "Dialup"; X`09break; X case (JPI$K_REMOTE): X`09string = "Remote"; X`09break; X default: X`09string = "Unkown"; X `7D X strcpy(jobtype_string, string); X`7D`09 Xget_state(state, state_txt) Xint`09state; Xchar`09*state_txt; X`7B X X char *string; X X switch (state) `7B X X case (SCH$C_CEF): X`09string = "CEF"; X`09break; X case (SCH$C_COM): X`09string = "COM"; X`09break; X case (SCH$C_COMO): X`09string = "COMO"; X`09break; X case (SCH$C_COLPG): X`09string = "COLPG"; X`09break; X case (SCH$C_CUR): X`09string = "CUR"; X`09break; X case (SCH$C_FPG): X`09string = "FPG"; X`09break; X case (SCH$C_HIB): X`09string = "HIB"; X`09break; X case (SCH$C_HIBO): X`09string = "HIBO"; X`09break; X case (SCH$C_LEF): X`09string = "LEF"; X`09break; X case (SCH$C_LEFO): X`09string = "LEFO"; X`09break; X case (SCH$C_MWAIT): X`09string = "MWAIT"; X`09break; X case (SCH$C_PFW): X`09string = "PFW"; X`09break; X case (SCH$C_SUSP): X`09string = "SUSP"; X`09break; X case (SCH$C_SUSPO): X`09string = "SUSPO"; X`09break; X default: X`09string = "UNK"; X `7D X strcpy(state_txt, string); X`7D`09 Xmailq() X`7B X FILE *fp; X int`09 i; X int`09 status; X int`09 found = FALSE; X int`09 context = 0; X int`09 to_found; X int`09 news_found; X int`09 date_found; X int`09 from_found; X char *cp; X char *search_start; X char *seq_start; X char *seq_end; X char *name_start; X char *name_end; X char *from_start; X char *from_end; X char file`5B256`5D; X char sequence`5B8`5D; X char mail_line`5B256`5D; X char to`5B256`5D; X char from`5B256`5D; X char date`5B256`5D; X char name`5B20`5D; X $DESCRIPTOR(file_desc, file); X $DESCRIPTOR(filespec_desc, "D"); X $DESCRIPTOR(default_desc, "UUCP_SPOOL:*.*;"); X X while (TRUE) `7B X`09status = lib$find_file (&filespec_desc, &file_desc, &context,`20 X`09`09&default_desc,0,0,0); X`09if (status != RMS$_NORMAL) `7B X`09 if (status == RMS$_FNF) `7B X`09`09printf("Mail queue is empty.\n"); X`09`09return; X`09 `7D X`09 if (status == RMS$_NMF) `7B X`09`09if (!found) printf ("Mail queue is empty.\n"); X`09`09lib$find_file_end(&context); X`09`09return; X`09 `7D X`09`7D X`09cp = strchr(file, ' '); X`09*cp = '\0'; X`09if ((fp = fopen(file, "r")) == NULL) `7B X`09 printf("Error opening %s\n", file); X`09 printf("\\%s\\\n", strerror(errno, 0)); X`09 exit(1); X`09`7D X`09from_found = FALSE; X`09to_found = FALSE; X`09date_found = FALSE; X`09news_found = FALSE; X`09strcpy(date, "Date unknown"); X`09strcpy(from, "From unknown"); X`09strcpy(to, "To unknown"); X X cp = strchr(file, '`5D'); X`09while (TRUE) `7B X`09 cp++; X`09 if ( *cp == 'D') break; X`09 cp = strchr(cp, '`5D'); X`09`7D X`09search_start = cp; X`09seq_start = strchr(search_start, '_'); X`09seq_end = strchr(search_start, ';'); X`09if (seq_start == NULL) seq_start = seq_end - 3; X`09else seq_start += 2; X`09*seq_end = '\0'; X`09for (cp = &sequence; *seq_start != '\0'; seq_start++) `7B X`09 if (*seq_start != '_') *cp++ = *seq_start; X`09`7D X`09*cp = '\0'; X`09name_start = strrchr(file, '`5D'); X`09name_start = strchr(name_start, '.'); X`09name_start++; X`09name_end = strchr(file, '_'); X`09if (name_end == NULL) name_end = seq_end - 4; X`09else name_end -= 1; X`09*name_end = '\0'; X`09strcpy( name, name_start); `20 X`09 X`09while (TRUE) `7B X`09 if (fgets(mail_line, 255, fp) == NULL) break; X`09 if (!strncmp(mail_line, "#! cunbatch", 11)) `7B X`09`09news_found = TRUE; X`09 `7D else if (!strncmp(mail_line, "To: ", 4) && !to_found) `7B X`09`09to_found = TRUE; X`09`09strcpy(to, &mail_line`5B4`5D); X`09 `7D else if (!strncmp(mail_line, "From: ", 6) && !from_found) `7B X`09`09from_found = TRUE; X`09`09from_start = strchr(mail_line, '<'); X`09`09if (from_start != NULL) `7B X`09`09 from_start++; X`09`09 from_end = strchr(from_start, '>'); X`09`09 *from_end = '\0'; X`09`09 strcpy(from, from_start); X`09`09`7D else `7B X`09`09 strcpy(from, &mail_line`5B6`5D); X`09`09`7D +-+-+-+-+-+-+-+- END OF PART 1 +-+-+-+-+-+-+-+-