home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / cmds / root.3 / usr / bin / extcompose / extcompose~
Text File  |  1998-08-19  |  9KB  |  303 lines

  1. #!/bin/sh
  2. # The following was generated from 
  3. # NLS/en/metamail.gen
  4. #
  5. MF_METAMAIL=metamail.cat@mail
  6. #
  7. MS_EXTCOMPOSE=1
  8. EXTCOMPOSE_MSG_WHERE=1
  9. EXTCOMPOSE_MSG_LOCAL=2
  10. EXTCOMPOSE_MSG_AFS=3
  11. EXTCOMPOSE_MSG_ANON=4
  12. EXTCOMPOSE_MSG_LOGIN=5
  13. EXTCOMPOSE_MSG_MAILSRVR=6
  14. EXTCOMPOSE_MSG_NUMBER=7
  15. EXTCOMPOSE_MSG_DOMAIN=8
  16. EXTCOMPOSE_MSG_DIR=9
  17. EXTCOMPOSE_MSG_NAME=10
  18. EXTCOMPOSE_MSG_TRANSFER=11
  19. EXTCOMPOSE_MSG_PATH=12
  20. EXTCOMPOSE_MSG_ADDR=13
  21. EXTCOMPOSE_MSG_ACCESS=14
  22. EXTCOMPOSE_MSG_CONTENT=15
  23. EXTCOMPOSE_MSG_ENCODED=16
  24. EXTCOMPOSE_MSG_NOT=17
  25. EXTCOMPOSE_MSG_BASE64=18
  26. EXTCOMPOSE_MSG_QP=19
  27. EXTCOMPOSE_MSG_UUENCODE=20
  28. EXTCOMPOSE_MSG_DATA=21
  29. EXTCOMPOSE_ERR_USAGE=22
  30. EXTCOMPOSE_ERR_CHOICE=23
  31. EXTCOMPOSE_ERR_EXIST=24
  32. #
  33. MS_GETFILENAME=2
  34. GETFILENAME_MSG_NAME=1
  35. GETFILENAME_ERR_NO_FILE=2
  36. #
  37. MS_METASEND=3
  38. METASEND_MSG_TO=1
  39. METASEND_MSG_SUBJECT=2
  40. METASEND_MSG_CC=3
  41. METASEND_MSG_CONTENT=4
  42. METASEND_MSG_FILE=5
  43. METASEND_MSG_ENC=6
  44. METASEND_MSG_NO=7
  45. METASEND_MSG_BASE64=8
  46. METASEND_MSG_QP=9
  47. METASEND_MSG_UUENCODE=10
  48. METASEND_ERR_S=11
  49. METASEND_ERR_C=12
  50. METASEND_ERR_SUB=13
  51. METASEND_ERR_T=14
  52. METASEND_ERR_E=15
  53. METASEND_ERR_F=16
  54. METASEND_ERR_M=17
  55. METASEND_ERR_OPTION=18
  56. METASEND_ERR_FILE=19
  57. METASEND_ERR_ANSWER=20
  58. METASEND_ERR_BATCH=21
  59. METASEND_ERR_DATAFILE=22
  60. METASEND_ERR_DELIVERY=23
  61. METASEND_ERR_DRAFT=24
  62. #
  63. MS_SHOWAUDIO=4
  64. SHOWAUDIO_MSG_CHOOSE=1
  65. SHOWAUDIO_MSG_SPEAKER=2
  66. SHOWAUDIO_MSG_TELEPHONE=3
  67. SHOWAUDIO_MSG_PREFER=4
  68. SHOWAUDIO_MSG_USE_PHONE=5
  69. SHOWAUDIO_MSG_FUTURE=6
  70. SHOWAUDIO_MSG_USE_SPEAKER=7
  71. SHOWAUDIO_MSG_SENDING=8
  72. SHOWAUDIO_MSG_AIFF=9
  73. SHOWAUDIO_MSG_NEXT=10
  74. SHOWAUDIO_MSG_DEV=11
  75. SHOWAUDIO_MSG_NUMBER=12
  76. SHOWAUDIO_MSG_CALLING=13
  77. SHOWAUDIO_MSG_DONE=14
  78. SHOWAUDIO_MSG_RSH=15
  79. SHOWAUDIO_MSG_CANT_PLAY=16
  80. #
  81. MS_SHOWEXTERNAL=5
  82. SHOWEXTERNAL_MSG_ANON=1
  83. SHOWEXTERNAL_MSG_FTP=2
  84. SHOWEXTERNAL_MSG_SRVR=3
  85. SHOWEXTERNAL_MSG_DATA=4
  86. SHOWEXTERNAL_MSG_SITE=5
  87. SHOWEXTERNAL_MSG_USER=6
  88. SHOWEXTERNAL_MSG_PASSWD=7
  89. SHOWEXTERNAL_MSG_BODY=8
  90. SHOWEXTERNAL_MSG_SU=9
  91. SHOWEXTERNAL_MSG_GETTING=10
  92. SHOWEXTERNAL_MSG_REQUESTED=11
  93. SHOWEXTERNAL_MSG_RM=12
  94. SHOWEXTERNAL_ERR_NAME=13
  95. SHOWEXTERNAL_ERR_USAGE=14
  96. SHOWEXTERNAL_ERR_FTP=15
  97. SHOWEXTERNAL_ERR_FOUND=16
  98. SHOWEXTERNAL_ERR_BODYFILE=17
  99. SHOWEXTERNAL_ERR_MAIL=18
  100. SHOWEXTERNAL_ERR_TYPE=19
  101. SHOWEXTERNAL_ERR_METAMAIL=20
  102. SHOWEXTERNAL_ERR_ENTER=21
  103. #
  104. MS_SHOWNONASCII=6
  105. SHOWNONASCII_MSG_DISPLAY=1
  106. SHOWNONASCII_MSG_XTERM=2
  107. #
  108. MS_SHOWPARTIAL=7
  109. SHOWPARTIAL_MSG_READ=1
  110. SHOWPARTIAL_MSG_WARN=2
  111. SHOWPARTIAL_MSG_SEV=3
  112. SHOWPARTIAL_MSG_TOTAL=4
  113. SHOWPARTIAL_MSG_FULL=5
  114. SHOWPARTIAL_ERR_USAGE=6
  115. SHOWPARTIAL_ERR_TREEROOT=7
  116. SHOWPARTIAL_ERR_ID=8
  117. SHOWPARTIAL_ERR_CP=9
  118. #
  119. MS_SHOWPICTURE=8
  120. SHOWPICTURE_MSG_DISPLAY=1
  121. SHOWPICTURE_MSG_NOTE=2
  122. # Copyright (c) 1998 The Santa Cruz Operation, Inc.. All Rights Reserved. 
  123. #                                                                         
  124. #        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE               
  125. #                   SANTA CRUZ OPERATION INC.                             
  126. #                                                                         
  127. #   The copyright notice above does not evidence any actual or intended   
  128. #   publication of such source code.                                      
  129.  
  130. #
  131. #    ident @(#) extcompose.sh 11.2 97/11/03 
  132. #
  133. #############################################################################
  134. #
  135. #    Copyright (c) 1997 The Santa Cruz Operation, Inc.. 
  136. #        All Rights Reserved. 
  137. #
  138. #    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF 
  139. #        THE SANTA CRUZ OPERATION INC.
  140. #    The copyright notice above does not evidence any
  141. #    actual or intended publication of such source code.
  142. #
  143. #############################################################################
  144. #
  145. # This file Copyright (c) 1992 Z-Code Software Corp.
  146. # Permission to use, copy, modify, and distribute this material
  147. # for any purpose and without fee is hereby granted, provided
  148. # that the above copyright notice and this permission notice
  149. # appear in all copies, and that the name of Z-Code Software not
  150. # be used in advertising or publicity pertaining to this
  151. # material without the specific, prior written permission
  152. # of an authorized representative of Z-Code.  Z-CODE SOFTWARE
  153. # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
  154. # OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS",
  155. # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  156. #
  157.  
  158. echo_n() {
  159.     echo "$@\c"
  160. }
  161.  
  162. :
  163.  
  164. if [ $# -lt 1 ]
  165. then
  166.     dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_ERR_USAGE \
  167.     "Usage:  $0 output-file-name\n" $0 1>&2
  168.     exit 1
  169. fi
  170. OUTFNAME=$1
  171.  
  172. choosing=yes
  173. while [ $choosing = yes ]
  174. do
  175.     echo ""
  176.     dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_WHERE \
  177.     "Where is the external data that you want this mail message to reference?\n"
  178.     dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_LOCAL \
  179.     "    1 -- In a local file\n"
  180.     dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_AFS \
  181.     "    2 -- In an AFS file\n"
  182.     dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_ANON \
  183.     "    3 -- In an anonymous FTP directory on the Internet\n"
  184.     dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_LOGIN \
  185.     "    4 -- In an Internet FTP directory that requires a valid login\n"
  186.     dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_MAILSRVR \
  187.     "    5 -- Under the control of a mail server that will send the data on request\n"
  188.     echo ""
  189.     dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_NUMBER \
  190.     "Please enter a number from 1 to 5: "
  191.     read ans
  192.     case "$ans" in
  193.         1) accesstype=local-file ;;
  194.     2) accesstype=afs ;;
  195.     3) accesstype=anon-ftp ;;
  196.     4) accesstype=ftp ;;
  197.     5) accesstype=mail-server ;;
  198.     * ) dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_ERR_CHOICE \
  199.         "That is NOT one of your choices.\n" 1>&2; continue ;;
  200.     esac
  201.  
  202.     case "$accesstype" in
  203.         ftp | anon-ftp )
  204.         dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_DOMAIN \
  205.         "Enter the full Internet domain name of the FTP site: "
  206.         read site
  207.         dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_DIR \
  208.         "Enter the name of the directory containing the file (RETURN for top-level): "
  209.         read directory
  210.         dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_NAME \
  211.         "Enter the name of the file itself: "
  212.         read name
  213.         dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_TRANSFER \
  214.         "Enter the transfer mode (type 'image' for binary data, RETURN otherwise): "
  215.         read mode
  216.         if [ -n "$mode" ]
  217.         then mode=ascii
  218.         fi
  219.         echo "Content-type: message/external-body; access-type=$accesstype; name="\"$name\"\; > $OUTFNAME
  220.         echo_n "    site="\"$site\" >> $OUTFNAME
  221.         if [ -n "$directory" ]
  222.         then echo_n "; directory="\"$directory\">> $OUTFNAME
  223.         fi
  224.         echo_n "; mode="\"$mode\">> $OUTFNAME
  225.         echo "">> $OUTFNAME
  226.         choosing=no
  227.         ;;
  228.  
  229.     local-file | afs )
  230.         name=
  231.         while [ -z "$name" ]
  232.         do
  233.             dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_PATH \
  234.             "Enter the full path name for the file: "
  235.         read name
  236.         if [ ! -f "$name" ]
  237.         then
  238.             dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE \
  239.             $EXTCOMPOSE_ERR_EXIST \
  240.             "The file $name does not seem to exist.\n" "$name"
  241.             name=
  242.         fi
  243.         done
  244.         echo "Content-type: message/external-body; access-type=$accesstype; name="\"$name\"> $OUTFNAME
  245.         choosing=no
  246.         ;;
  247.     
  248.     mail-server )
  249.         dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_ADDR \
  250.         "Enter the full email address for the mailserver: "
  251.         read server
  252.         echo "Content-type: message/external-body; access-type=$accesstype; server="\"$server\"> $OUTFNAME
  253.         choosing=no
  254.         ;;
  255.     
  256.     * )
  257.         dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_ACCESS \
  258.         "access type $accesstype not yet implemented\n" "$accesstype"
  259.         ;;
  260.     esac
  261. done
  262.  
  263. dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_CONTENT \
  264.     "Please enter the MIME content-type for the externally referenced data: "
  265. read ctype
  266.  
  267. choosing=yes
  268. while [ $choosing = yes ]
  269. do
  270.     dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_ENCODED \
  271.     "Is this data already encoded for email transport?\n"
  272.     dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_NOT \
  273.     "  1 -- No, it is not encoded\n"
  274.     dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_BASE64 \
  275.     "  2 -- Yes, it is encoded in base64\n"
  276.     dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_QP \
  277.     "  3 -- Yes, it is encoded in quoted-printable\n"
  278.     dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_UUENCODE \
  279.     "  4 -- Yes, it is encoded using uuencode\n"
  280.     read encode
  281.     case "$encode" in
  282.     1 ) cenc="" choosing=no ;;
  283.     2 ) cenc="base64" choosing=no ;;
  284.     3 ) cenc="quoted-printable" choosing=no ;;
  285.     4 ) cenc="x-uue" choosing=no ;;
  286.     * ) dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_ERR_CHOICE \
  287.         "That is not one of your choices.\n" ;;
  288.     esac
  289. done
  290.  
  291. echo "" >> $OUTFNAME
  292. echo "Content-type: " $ctype >> $OUTFNAME
  293. if [ -n "$cenc" ]
  294. then echo "Content-transfer-encoding: " $cenc >> $OUTFNAME
  295. fi
  296. echo "" >> $OUTFNAME
  297. if [ "$accesstype" = "mail-server" ]
  298. then
  299.     dspmsg $MF_METAMAIL -s $MS_EXTCOMPOSE $EXTCOMPOSE_MSG_DATA \
  300.     "Please enter all the data to be sent to the mailserver in the message body, \nending with ^D or your usual end-of-data character:\n"
  301.     cat >> $OUTFNAME
  302. fi
  303.