#!/bin/csh
 
# This script finds recursively all the checked out SCCS files and
# checks them in              PK Feb 93
#
# THIS SAMPLE PROGRAM IS BEING PROVIDED "AS IS" AND ONLY AS A COURTESY TO
# THE RECIPIENT.  SUN MAKES NO WARRANTY OR REPRESENTATION, EITHER EXPRESS 
# OR IMPLIED WITH RESPECT TO THIS SAMPLE PROGRAM INCLUDING QUALITY, PERF- 
# FORMANCE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON- 
# INFRINGEMENT.  IN NO EVENT WILL SUN BE LIABLE FOR ANY DIRECT, INDIRECT,  
# SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR  
# INABILITY TO USE THIS SAMPLE PROGRAM.

set OSBIN=/os/bin

if ( -d /usr/ccs ) then
     set TEAMWARE_BIN=/lab/teamware/Solaris2.0/bin
     set SCCS_BIN=/usr/ccs/bin
else
         set TEAMWARE_BIN=/lab/teamware/Solaris1.0
     set SCCS_BIN=/usr/sccs
endif  
 
if ("$1" == "-n") then
   set check_in_flag="false"
   shift
else
   set check_in_flag="true"
endif
set comment="$*"
 
set current_dir=`pwd`
echo PHASE 1 of 2: Looking for SCCS dirs...
set sccs_dirs=`find . -name SCCS -print | xargs`
echo Done.
 
if ("$check_in_flag" == "true") then
        echo PHASE 2 of 2: Looking for, reporting, and checking in  checked out files...
else
        echo PHASE 2 of 2: Looking for and reporting checked out files...
endif
foreach  sccs_dir ($sccs_dirs)
   cd ${current_dir}/${sccs_dir}
   set exists_cof_flag="false"
   # Find all the checked out files
   set psccs_files=`find . -name "p.*" -print | xargs`
   foreach psccs_file ($psccs_files)
          # Set the flag to print the directory
          set exists_cof_flag="true"
      # Substutute the p.* with s.*
          set ssccs_file=`echo $psccs_file | sed  's/^.\/p./s./g'`
          set file=`echo $psccs_file | sed  's/^.\/p.//g'`
          cd ..
          echo "***" delta -n -y\"$comment\" SCCS/${ssccs_file}
          if ("$check_in_flag" == "true") then
                ${SCCS_BIN}/delta -n -y"$comment" SCCS/${ssccs_file} > /dev/null
                chmod -w $file
          endif
          cd SCCS
   end
   if ("$exists_cof_flag" == "true") then
          echo in ${current_dir}/${sccs_dir}
   endif
end

