#!/bin/sh # $RCSfile: ng_dump_functions,v $ $Revision: 1.3 $ $Date: 2003/10/28 05:33:37 $ # $AIST_Release: 4.2.4 $ # $AIST_Copyright: # Copyright 2003, 2004, 2005, 2006 Grid Technology Research Center, # National Institute of Advanced Industrial Science and Technology # Copyright 2003, 2004, 2005, 2006 National Institute of Informatics # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # $ # # ng_dump_functions # LANG=C PATH="/bin:/usr/bin" funcname="GridRPC-Funcname" modulename="GridRPC-Module" ldif_dir="${GLOBUS_LOCATION}/var/gridrpc" headline_func='Module/Entry' headline_owner='Owner' output_format='%-10s %-32s\n' # is_funcname returns 1 if arg is Module/Entry, 0 if arg is Module is_funcname () { name=$1 echo $name | \ grep '^[a-zA-Z0-9_$][a-zA-Z0-9_$]*/[a-zA-Z0-9_$][a-zA-Z0-9_$]*$' \ 1>/dev/null 2>&1 if [ $? -eq 0 ]; then return 1 else echo $name | \ grep '^[a-zA-Z0-9_$][a-zA-Z0-9_$]*$' 1>/dev/null 2>&1 if [ $? -eq 0 ]; then return 0 else echo "Error: Illegal Module or Module/Entry name \"${name}\"." >&2 exit 1 fi fi } dump_items=$* if [ "X${dump_items}" = "X" ]; then dump_type="all" else dump_type="items" fi entries=`(ls -l ${ldif_dir}/*::*.ldif | awk '{print $9 " " $3}') 2>/dev/null` # entries="file1 owner1 file2 owner2 ..." if [ $? -ne 0 -o "X${entries}" = "X" ]; then echo "Error: No ldif file installed in ${ldif_dir}" >&2 exit 1 fi printf "${output_format}" $headline_owner $headline_func file_or_owner="file" for ent in $entries ; do if [ "X${file_or_owner}" = "Xfile" ]; then file=$ent func=`awk "/^${funcname}:/{print \\\$2 }" ${file}` if [ $? -ne 0 -o "X${func}" = "X" ]; then echo "Error : ldif file format error in \"${file}\"." >&2 exit 1 fi file_or_owner="owner" else # $file_or_owner = owner owner=$ent should_print=0 if [ "X${dump_type}" = "Xitems" ]; then module=`awk "/^${modulename}:/{print \\\$2 }" ${file}` if [ $? -ne 0 -o "X${module}" = "X" ]; then echo \ "Error : ldif file format error in \"${file}\"." >&2 exit 1 fi for ditem in $dump_items ; do is_funcname $ditem if [ $? -eq 1 ]; then # $ditem = Module/Entry if [ "X${ditem}" = "X${func}" ]; then should_print=1 break fi else # $ditem = Module if [ "X${ditem}" = "X${module}" ]; then should_print=1 break fi fi done else # $dump_type = all should_print=1 fi if [ $should_print -eq 1 ]; then printf "${output_format}" $owner $func fi file_or_owner="file" fi done exit 0