C************************************************************************
C*
C*  COPYRIGHT (c) 1981,1983,1984,1987,1988
C*  Westinghouse Electric Corporation
C*
C*  THIS SOFTWARE IS FURNISHED WITHOUT LICENSE AND MAY BE USED AND
C*  COPIED ONLY WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.
C*
C*  THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE
C*  AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY WESTINGHOUSE.
C*
C*  WESTINGHOUSE ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY
C*  OF THIS SOFTWARE.
C*
C****************************************************************************
C	SHOWUIC.FOR
C
C	SHOW_UIC types the SOFTQUOTA.DAT file for the current drive.
C
      subroutine show_uic (chan, uic_in, usehard, *)

      implicit integer (a-z)

      include '($FORIOSDEF)'
      include 'iodef/nolist'

      integer*2 group, member, i2uic(2)
      integer*4 temp_uic
      equivalence (temp_uic, i2uic(1))
      character heading*40, title*132, day*9, tme*9
      character group_member*32, uic_string*32
      logical flag
      common /listchar/ day, tme, heading, title

 110  format (1x,a,/,1x,a,t20,i8,2x,i8,2x,i8,2x,i8,2x,i7,2x,i7)
 120  format (10x,a,t26,i8,t37,i7,t48,i7)
 130  format (' %SOFTDB-ERR  UIC ',a,3x,a,' was not found in ',
     .        a, a)
 140  format ('----------------------------------------',
     1        '----------------------------------------',/,
     2        ' Totals ',t20,i8,2x,i8,2x,i8)

      title (1:12) = ' '
      title (13:) = '[UIC]   Softquota Permquota   Usage   Overdraft'
     1              //' Hardsave Messages'

      temp_uic = uic_in
      member = i2uic(1)
      group = i2uic(2)

      if (group .lt. 0 .or. member .lt. 0) then            ! entire file

        heading = 'Softquota Listing of '//drive(1:drive_len)
        if (chan .eq. print_chan) then
          call print_heading
        else
          call type_heading
        end if
        total_soft = 0
        total_hard = 0
        total_usage = 0

        if (group .ge. 0) then
          flag = .false.
          if (usehard .eq. 0) then
            call read_soft_key (2, group, uic, soft, hard, mess, ios)
            call get_hard_quota (uic, quota, usage, over)
          else
            uic = uic_in
            call get_hard_quota_index (0, uic, quota, usage, over,
     1                                 context, status)
            soft = 0
            hard = 0
            mess = 0
            call read_soft (uic, uic, soft, hard, mess, ios)
c            if (status .ne. 1) flag = .false.
            IF (status .eq. 1 .and. ios .ne. 0) THEN
              status = sys$fao ('!%I',luic, uic_string, %val(uic))
              write (chan,*) '%SOFTQ-E-NODISKQUOTA',
     .               ' no SOFT disk quota entry on ',drive(1:drive_len),
     .               ' for ', uic_string (1 : luic)
              ios = 0
            end if
          end if
          temp_uic = uic
          if (group .eq. i2uic(2)) flag = .true.
              
          do while (ios .eq. 0 .and. flag)
            group_member = '         '
            total_soft = total_soft + soft
            status = sys$fao ('!%U',lgroup, group_member, %val(uic))
            status = sys$fao ('!%I',luic, uic_string, %val(uic))
            total_hard = total_hard + quota
            total_usage = total_usage + usage
            write (chan, 110) uic_string(1:luic),
     1                        group_member(1:lgroup), soft, quota,
     1                        usage, over, hard, mess
            if (chan .eq. print_chan) then
              call end_page (2)
            else
              call end_screen (2, &800)
            end if
            if (usehard .eq. 0) then
              call read_soft_next (uic, soft, hard, mess, ios)
              call get_hard_quota (uic, quota, usage, over)
            else
              call get_hard_quota_index (0, uic, quota, usage, over,
     1                                   context, status)
              soft = 0
              hard = 0
              mess = 0
              call read_soft (uic, uic, soft, hard, mess, ios)
              if (status .ne. 1) flag = .false.
              IF (status .eq. 1 .and. ios .ne. 0) THEN
                status = sys$fao ('!%I',luic, uic_string, %val(uic))
                write (chan,*) '%SOFTQ-E-NODISKQUOTA',
     .               ' no SOFT disk quota entry on ',drive(1:drive_len),
     .               ' for ', uic_string (1 : luic)
                ios = 0
              end if
            end if
            temp_uic = uic
            if (group .ne. i2uic(2)) flag = .false.
          end do
          write (chan, 140) total_soft, total_hard, total_usage !print total
         else if (member .ge. 0) then
          flag = .false.
          if (usehard .eq. 0) then
            call read_soft_key (1, member, uic, soft, hard, mess, ios)
            call get_hard_quota (uic, quota, usage, over)
          else
            uic = uic_in
            call get_hard_quota_index (1, uic, quota, usage, over,
     1                                 context, status)
            soft = 0
            hard = 0
            mess = 0
            call read_soft (uic, uic, soft, hard, mess, ios)
c            if (status .ne. 1) flag = .false.
            IF (status .eq. 1 .and. ios .ne. 0) THEN
              status = sys$fao ('!%I',luic, uic_string, %val(uic))
              write (chan,*) '%SOFTQ-E-NODISKQUOTA',
     .               ' no SOFT disk quota entry on ',drive(1:drive_len),
     .               ' for ', uic_string (1 : luic)
              ios = 0
            end if
          end if
          temp_uic = uic
          if (member .eq. i2uic(1)) flag = .true.
          do while (ios .eq. 0 .and. flag)
            group_member = '         '
            total_soft = total_soft + soft
            status = sys$fao ('!%U',lgroup, group_member, %val(uic))
            status = sys$fao ('!%I',luic, uic_string, %val(uic))
            total_hard = total_hard + quota
            total_usage = total_usage + usage
            write (chan, 110) uic_string(1:luic),
     1                        group_member(1:lgroup), soft, quota,
     1                        usage, over, hard, mess
            if (chan .eq. print_chan) then
              call end_page (2)
            else
              call end_screen (2, &800)
            end if
            if (usehard .eq. 0) then
              call read_soft_next (uic, soft, hard, mess, ios)
              call get_hard_quota (uic, quota, usage, over)
            else
              call get_hard_quota_index (1, uic, quota, usage, over,
     1                                   context, status)
              soft = 0
              hard = 0
              mess = 0
              call read_soft (uic, uic, soft, hard, mess, ios)
              if (status .ne. 1) flag = .false.
              IF (status .eq. 1 .and. ios .ne. 0) THEN
                status = sys$fao ('!%I',luic, uic_string, %val(uic))
                write (chan,*) '%SOFTQ-E-NODISKQUOTA',
     .               ' no SOFT disk quota entry on ',drive(1:drive_len),
     .               ' for ', uic_string (1 : luic)
                ios = 0
              end if
            end if
            temp_uic = uic
            if (member .ne. i2uic(1)) flag = .false.
          end do
          write (chan, 140) total_soft, total_hard, total_usage ! type total
        else if (member .eq. -2) then
          call read_soft_key (1, member, uic, soft, hard, mess, ios)
          if (ios .eq. 0) then
            write (chan, 120) 'Drive Default', soft, hard, mess
            if (chan .eq. print_chan) then
              call end_page (2)
            else
              call end_screen (2, &800)
            end if
          end if
        else if (member .eq. -3) then
          call read_soft_key (1, member, uic, soft, hard, mess, ios)
          if (ios .eq. 0) then
            write (chan, 120) 'User Default', soft, hard, mess
            if (chan .eq. print_chan) then
              call end_page (2)
            else
              call end_screen (2, &800)
            end if
          end if
        else
          if (usehard .eq. 0) then
            call read_soft_first (uic, soft, hard, mess, ios)
            call get_hard_quota (uic, quota, usage, over)
          else
            uic = uic_in
            call get_hard_quota_index (2, uic, quota, usage, over,
     1                                 context, status)
            soft = 0
            hard = 0
            mess = 0
            call read_soft (uic, uic, soft, hard, mess, ios)
            if (status .ne. 1) ios = 1
            IF (status .eq. 1 .and. ios .ne. 0) THEN
              status = sys$fao ('!%I',luic, uic_string, %val(uic))
              write (chan,*) '%SOFTQ-E-NODISKQUOTA',
     .               ' no SOFT disk quota entry on ',drive(1:drive_len),
     .               ' for ', uic_string (1 : luic)
              ios = 0
            end if
          end if
          do while (ios .eq. 0)
            group_member = '         '
            status = sys$fao ('!%U',lgroup, group_member, %val(uic))
            status = sys$fao ('!%I',luic, uic_string, %val(uic))
            IF (overquota) then
              IF (usage .gt. soft) THEN
                write (chan, 110) uic_string(1:luic),
     1                        group_member(1:lgroup), soft, quota,
     1                        usage, over, hard, mess
                call end_page (2)
                total_soft = total_soft + soft
                total_hard = total_hard + quota
                total_usage = total_usage + usage
              END IF
            ELSE
              write (chan, 110) uic_string(1:luic),
     1                        group_member(1:lgroup), soft, quota,
     1                        usage, over, hard, mess
              total_soft = total_soft + soft
              total_hard = total_hard + quota
              total_usage = total_usage + usage
              if (chan .eq. print_chan) then
                call end_page (2)
              else
                call end_screen (2, &800)
              end if
            end if
            if (usehard .eq. 0) then
              call read_soft_next (uic, soft, hard, mess, ios)
              call get_hard_quota (uic, quota, usage, over)
            else
              call get_hard_quota_index (2, uic, quota, usage, over,
     1                                   context, status)
              soft = 0
              hard = 0
              mess = 0
              call read_soft (uic, uic, soft, hard, mess, ios)
              if (status .ne. 1) ios = 1
              IF (status .eq. 1 .and. ios .ne. 0) THEN
                status = sys$fao ('!%I',luic, uic_string, %val(uic))
                write (chan,*) '%SOFTQ-E-NODISKQUOTA',
     .               ' no SOFT disk quota entry on ',drive(1:drive_len),
     .               ' for ', uic_string (1 : luic)
                ios = 0
              end if
            end if
          end do
          write (chan, 140) total_soft, total_hard, total_usage !type total
        end if

      else                                          ! single record

        heading = ' '
        call read_soft (uic_in, uic, soft, hard, mess, ios) ! get [g,m]
        call get_hard_quota (uic, quota, usage, over)

        if (ios .eq. 0) then
          if (chan .eq. print_chan) then
            call print_heading
          else
            call type_heading
          end if
          group_member = '         '
            status = sys$fao ('!%U',lgroup, group_member, %val(uic))
            status = sys$fao ('!%I',luic, uic_string, %val(uic))
            write (chan, 110) uic_string(1:luic),
     1                        group_member(1:lgroup), soft, quota,
     1                        usage, over, hard, mess
          if (chan .eq. print_chan) then
            call end_page (2)
          else
            call end_screen (2, &800)
          end if
        else if (ios .eq. FOR$IOS_ATTACCNON) then
          group_member = '         '
          status = sys$fao ('!%U', lgroup, group_member, %val(uic_in))
          status = sys$fao ('!%I', luic, uic_string, %val(uic_in))
          write (chan, 130) uic_string(1:luic), ' ',
     1                      group_member(1:lgroup),
     1                      drive(1:drive_len), DataFile
        endif

      endif

      return
 800  return 1
      end
