#! /bin/sh
# $Id: storeparts 1.0 1995/07/12 14:37:22 jerry book3 $
#
### storeparts - find all parts of current message/partial and store them
### Usage: storeparts [msgs]
##
##  storeparts gets the "id=" field from the Content-Type: header
##  field of the current message.  Then it searches for other parts
##  with the same id= string and gives the messages to 'mhn -store'.
##
##  msgs is the list of messages in the current folder to search for
##  other parts.  The default is all messages.
# 
#                             NO WARRANTY
# 
#   BECAUSE THIS PROGRAM IS AVAILABLE FREE OF CHARGE, THERE IS NO WARRANTY
# FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
# OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
# PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
# OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
# TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
# PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
# REPAIR OR CORRECTION.
# 
#   IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
# WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
# REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
# INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
# OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
# TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
# YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
# PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGES.


# GET "id=" STRING FROM CURRENT MESSAGE:
ctype=`scan -format '%{content-type}' cur` || exit
id=`expr "$ctype" : '.*\(id="[^"]*"\)'` || exit
echo "`basename $0`: searching for '$id'." 1>&2
# FIND MESSAGES IN $1 (DEFAULT: ALL MESSAGES) WITH $id IN "Content-Type:".
# STORE IN temp SEQUENCE:
pick --content-type "$id" -seq temp $1 || exit
# IF pick DIDN'T FIND ALL MESSAGES, mhn WILL COMPLAIN AND QUIT:
mhn -store temp
