1 #!/bin/ksh
   2 #
   3 # This file and its contents are supplied under the terms of the
   4 # Common Development and Distribution License ("CDDL"), version 1.0.
   5 # You may only use this file in accordance with the terms of version
   6 # 1.0 of the CDDL.
   7 #
   8 # A full copy of the text of the CDDL should have accompanied this
   9 # source.  A copy of the CDDL is also available via the Internet at
  10 # http://www.illumos.org/license/CDDL.
  11 #
  12 
  13 #
  14 # Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  15 
  16 # List all iconv(1) codesets
  17 
  18 cd /usr/lib/iconv || exit 1
  19 
  20 typeset -A all
  21 
  22 /usr/bin/ls | while read f
  23 do
  24     case "$f" in
  25     geniconvtbl.so)
  26         ;;
  27     *.so)
  28         IFS="%"
  29         set ${f%.so}
  30         all[$1]=" "
  31         all[$2]=" "
  32         ;;
  33     *.t)
  34         IFS="."
  35         set ${f%.t}
  36         all[$1]=" "
  37         all[$2]=" "
  38         ;;
  39     *)
  40         ;;
  41     esac
  42 done
  43 
  44 /usr/bin/ls geniconvtbl/binarytables |
  45 while read f
  46 do
  47     case "$f" in
  48     *.bt)
  49         IFS="%"
  50         set ${f%.bt}
  51         all[$1]=" "
  52         all[$2]=" "
  53         ;;
  54     *)
  55         ;;
  56     esac
  57 done
  58 
  59 # Only store aliases for names we've seen
  60 
  61 IFS="   "
  62 while read a c
  63 do
  64     case "$a" in
  65     \#*)
  66         ;;
  67     *)
  68         if [ "$c" -a "${all[$c]}" ] ; then
  69                 all[$c]="${all[$c]} $a"
  70         fi
  71         ;;
  72     esac
  73 done < "alias"
  74 
  75 cat <<EOF
  76 The following are all supported code set names.  Conversions
  77 between some fromcode-tocode pairs might not be available.
  78 Some of these code set names have aliases, which are shown
  79 after the canonical name.
  80 
  81 EOF
  82 
  83 for i in "${!all[@]}"
  84 do
  85         echo "$i ${all[$i]}"
  86 done