From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 14-NOV-1990 07:56:20.45
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	PLM$MAIL, part 8 of 10

Received:  by crdgw1.ge.com (5.57/GE 1.76)
	 id AA02724; Wed, 14 Nov 90 07:21:11 EST
Received: From ICNUCEVM.CNUCE.CNR.IT by CRVAX.SRI.COM with TCP; Wed, 14 NOV 90 01:36:38 PST
Received: from ITOPOLI.BITNET by ICNUCEVM.CNUCE.CNR.IT (IBM VM SMTP R1.2.2MX) with BSMTP id 0277; Wed, 14 Nov 90 10:33:21 MET
Date: Wed, 14 Nov 90 10:32 GMT+1
From: "P.L. Montessoro * CENS-CNR * +39-11-556.7013" <PIERLUCA%ITOPOLI.BITNET@ICNUCEVM.CNUCE.CNR.IT>
Subject: PLM$MAIL, part 8 of 10
To: info-vax@kl.sri.com
Message-Id: <04DB9A89E45F20028A@ITOPOLI.BITNET>
X-Envelope-To: info-vax@kl.sri.com
X-Vms-To: INFOVAX

-+-+-+-+-+-+-+-+ START OF PART 8 -+-+-+-+-+-+-+-+
X#if FALSE
X                     lib$signal (status);
X#endif
X                     printf ("\n\n");
X                  `125
X                  goto READ_COMM;
X               `125
X               trim (int_buffer);
X            `125  while ((int_buffer `0910`093 != 'y') && (int_buffer `0910`
V093 != 'Y') &&`032
X                      (int_buffer `0910`093 != 'n') && (int_buffer `0910`093
V != 'N'));
X  `032
X            if ((int_buffer `0910`093 == 'y') `124`124 (int_buffer `0910`093
V == 'Y'))
X            `123
X               /* generate a filename for the message */
X               build_sendmsg_filename (filename_buffer);
X
X               /* edit the file */          `032
X               tpuedit (filename, filename_buffer);
X
X               edit_flag = TRUE;
X            `125
X            else
X            `123
X               /* send the file */
X               strcpy (filename_buffer, filename);
X
X               edit_flag = FALSE;
X            `125
X         `125
X         else
X         `123
X            /* generate a filename for the message */
X            build_sendmsg_filename (filename_buffer);
X
X            /* edit the file */          `032
X            tpuedit ("", filename_buffer);
X
X            edit_flag = TRUE;
X         `125
X
X         /* does the file exist? */
X         if ((fp = fopen (filename_buffer, "r")) == NULL)
X         `123
X            printf ("PLM$MAIL-F-NOFILE, File %s not found\n", filename_buffe
Vr);
X            if ((status = mail$send_abort`032
X                             (&send_context,`032
X                              &mail_null_list,`032
X                              &mail_null_list)) != SS$_NORMAL)
X            `123
X#if FALSE
X               lib$signal (status);
X#endif
X               printf ("\n\n");
X            `125
X            if ((status = mail$send_end`032
X                             (&send_context,`032
X                              &mail_null_list,`032
X                              &mail_null_list)) != SS$_NORMAL)
X            `123
X#if FALSE
X               lib$signal (status);
X#endif
X               printf ("\n\n");
X            `125
X            goto READ_COMM;
X         `125
X         fclose (fp);
X
X         /* confirm? */
X         printf ("\n\n");
X         do
X         `123
X            printf ("Confirm? ");
X            if (gets (int_buffer) == NULL)
X            `123
X               /* control Z */
X               if ((status = mail$send_abort`032
X                                (&send_context,`032
X                                 &mail_null_list,`032
X                                 &mail_null_list)) != SS$_NORMAL)
X               `123
X#if FALSE
X                  lib$signal (status);
X#endif
X                  printf ("\n\n");
X               `125
X               if ((status = mail$send_end`032
X                                (&send_context,`032
X                                 &mail_null_list,`032
X                                 &mail_null_list)) != SS$_NORMAL)
X               `123
X#if FALSE
X                  lib$signal (status);
X#endif
X                  printf ("\n\n");
X               `125
X               goto READ_COMM;
X            `125
X            trim (int_buffer);
X         `125  while ((int_buffer `0910`093 != 'y') && (int_buffer `0910`093
V != 'Y') &&`032
X                   (int_buffer `0910`093 != 'n') && (int_buffer `0910`093 !=
V 'N'));
X
X         if ((int_buffer `0910`093 == 'n') `124`124 (int_buffer `0910`093 ==
V 'N'))
X         `123
X            if ((status = mail$send_abort`032
X                             (&send_context,`032
X                              &mail_null_list,`032
X                              &mail_null_list)) != SS$_NORMAL)
X            `123
X#if FALSE
X               lib$signal (status);
X#endif
X               printf ("\n\n");
X            `125
X            if ((status = mail$send_end`032
X                             (&send_context,`032
X                              &mail_null_list,`032
X                              &mail_null_list)) != SS$_NORMAL)
X            `123
X#if FALSE
X               lib$signal (status);
X#endif
X               printf ("\n\n");
X            `125
X
X            if (edit_flag)
X            `123
X               /* delete the temporary file */
X               strcat (filename_buffer, ";0");   /* last version */
X               while (!delete (filename_buffer));  /* all the versions */
X            `125
X
X            goto READ_COMM;
X         `125                  `032
X
X         message_send_filename_itmlst`0910`093.buffer_address = filename_buf
Vfer;
X         message_send_filename_itmlst`0910`093.buffer_length =`032
X                                                 strlen (filename_buffer);
X         if ((status = mail$send_add_bodypart`032
X                          (&send_context,`032
X                           &message_send_filename_itmlst,`032
X                           &mail_null_list)) != SS$_NORMAL)
X         `123
X#if FALSE
X            lib$signal (status);
X#endif
X            printf ("\n\n");
X         `125
X
X         if ((status = mail$send_message`032
X                          (&send_context,`032
X                           &mail_null_list,`032
X                           &mail_null_list)) != SS$_NORMAL)
X         `123
X#if FALSE
X            lib$signal (status);
X#endif
X            printf ("\n\n");
X            if ((status = mail$send_abort`032
X                             (&send_context,`032
X                              &mail_null_list,`032
X                              &mail_null_list)) != SS$_NORMAL)
X            `123
X#if FALSE
X               lib$signal (status);
X#endif
X               printf ("\n\n");
X            `125
X         `125
X
X         if ((status = mail$send_end`032
X                          (&send_context,`032
X                           &mail_null_list,`032
X                           &mail_null_list)) != SS$_NORMAL)
X         `123
X#if FALSE
X            lib$signal (status);
X#endif
X            printf ("\n\n");
X         `125
X
X         if (edit_flag)
X         `123
X            /* delete the temporary file */
X            strcat (filename_buffer, ";0");   /* last version */
X            while (!delete (filename_buffer));  /* all the versions */
X         `125
X
X         goto READ_COMM;
X         break;
X
X      case 'r':
X      case 'R':
X         /* reply to a message */
X         if ((curr_message == BEG_OF_MSG_LIST) `124`124
X             (curr_message == END_OF_MSG_LIST))
X         `123
X            printf ("PLM$MAIL-E-NOCURRMSG, No message selected as current\n"
V);
X            goto READ_COMM;
X         `125
X
X         send_context = 0;
X         if ((status = mail$send_begin`032
X                          (&send_context,`032
X                           &mail_null_list,`032
X                           &mail_null_list)) != SS$_NORMAL)
X         `123
X#if FALSE
X            lib$signal (status);
X#endif
X            printf ("\n\n");
X         `125
X
X         /* get the destination from the 'from' field (first string) */
X         sscanf (curr_message->from, "%s", to_buffer);
X         to_length = strlen (to_buffer);
X         message_send_address_itmlst`0910`093.buffer_address = to_buffer;
X         message_send_address_itmlst`0910`093.buffer_length = strlen (to_buf
Vfer);
X         if ((status = mail$send_add_address`032
X                          (&send_context,`032
X                           &message_send_address_itmlst,`032
X                           &mail_null_list)) != SS$_NORMAL)
X         `123
X#if FALSE
X            lib$signal (status);
X#endif
X            printf ("\n\n");
X            /* abort */
X            if ((status = mail$send_end`032
X                             (&send_context,`032
X                              &mail_null_list,`032
X                              &mail_null_list)) != SS$_NORMAL)
X            `123
X#if FALSE
X               lib$signal (status);
X#endif
X               printf ("\n\n");
X            `125
X            goto READ_COMM;
X         `125
X
X         /* subject */
X         sprintf (subj_buffer, "Re: %s", curr_message->subject);
X         printf ("Subject `091 %s `093: ", subj_buffer);
X         if (gets (int_buffer) == NULL)
X         `123
X            /* control Z */
X            if ((status = mail$send_end`032
X                             (&send_context,`032
X                              &mail_null_list,`032
X                              &mail_null_list)) != SS$_NORMAL)
X            `123
X#if FALSE
X               lib$signal (status);
X#endif
X               printf ("\n\n");
X            `125
X            goto READ_COMM;
X         `125
X         trim (int_buffer);
X         if (int_buffer `0910`093 != '\0')
X            strcpy (subj_buffer, int_buffer);
X
X         message_send_attribute_itmlst`0910`093.buffer_address = subj_buffer
V;
X         message_send_attribute_itmlst`0910`093.buffer_length = strlen (subj
V_buffer);
X         if ((status = mail$send_add_attribute
X                          (&send_context,`032
X                           &message_send_attribute_itmlst,`032
X                           &mail_null_list)) != SS$_NORMAL)
X         `123
X#if FALSE
X            lib$signal (status);
X#endif
X            printf ("\n\n");
X         `125
X
X         /* generate a filename for the message */
X         build_sendmsg_filename (filename_buffer);
X
X         /* copy the message into the file */
X         if ((fp = fopen (filename_buffer, "w")) == NULL)
X         `123
X            printf ("PLM$MAIL-F-OPENERR, Cannot create file %s\n", filename)
V;
X            /* abort */
X            if ((status = mail$send_end`032
X                             (&send_context,`032
X                              &mail_null_list,`032
X                              &mail_null_list)) != SS$_NORMAL)
X            `123
X#if FALSE
X               lib$signal (status);
X#endif
X               printf ("\n\n");
X            `125
X            goto READ_COMM;
X         `125
X
X         /* select the message */
X         msg_id = curr_message->id;
X         status = mail$message_get`032
X                     (&message_context,`032
X                      message_sel_msg_in_itmlst,
X                      mail_null_list);
X         if (status != MAIL$_MSGINFO)
X         `123
X#if FALSE
X            lib$signal (status);
X#endif
X            printf ("\n\n");
X         `125          `032
X         do
X         `123
X            /* get a record of the message */
X            status = mail$message_get`032
X                        (&message_context,`032
X                         message_get_record_in_itmlst,`032
X                         message_get_record_out_itmlst);
X            if ((status != MAIL$_MSGTEXT) &&`032
X                (status != MAIL$_NOMOREREC))
X            `123
X#if FALSE
X               lib$signal (status);
X#endif
X               printf ("\n\n");
X               break;
X            `125
X            msg_buffer `091msg_length`093 = '\0';
X            if (status != MAIL$_NOMOREREC)
X            `123
X               sprintf (int_buffer, "> %s", msg_buffer);
X               fprintf (fp, "%s\n", int_buffer);
X            `125
X         `125  while (status != MAIL$_NOMOREREC);
X         fclose (fp);
X
X         /* edit the file */          `032
X         tpuedit (filename_buffer, filename_buffer);
X
X         /* does the file exist? */
X         if ((fp = fopen (filename_buffer, "r")) == NULL)
X         `123
X            printf ("PLM$MAIL-F-NOFILE, File %s not found\n", filename_buffe
Vr);
X            if ((status = mail$send_abort`032
X                             (&send_context,`032
X                              &mail_null_list,`032
X                              &mail_null_list)) != SS$_NORMAL)
X            `123
X#if FALSE
X               lib$signal (status);
X#endif
X               printf ("\n\n");
X            `125
X            if ((status = mail$send_end`032
X                             (&send_context,`032
X                              &mail_null_list,`032
X                              &mail_null_list)) != SS$_NORMAL)
X            `123
X#if FALSE
X               lib$signal (status);
X#endif
X               printf ("\n\n");
X            `125
X            goto READ_COMM;
X         `125
X         fclose (fp);
X
X         /* confirm? */
X         printf ("\n\n");
X         do
X         `123
X            printf ("Confirm? ");
X            if (gets (int_buffer) == NULL)
X            `123
X               /* control Z */
X               if ((status = mail$send_abort`032
X                                (&send_context,`032
X                                 &mail_null_list,`032
X                                 &mail_null_list)) != SS$_NORMAL)
X               `123
X#if FALSE
X                  lib$signal (status);
X#endif
X                  printf ("\n\n");
X               `125
X               if ((status = mail$send_end`032
X                                (&send_context,`032
X                                 &mail_null_list,`032
X                                 &mail_null_list)) != SS$_NORMAL)
X               `123
X#if FALSE
X                  lib$signal (status);
X#endif
X                  printf ("\n\n");
X               `125
X               goto READ_COMM;
X            `125
X            trim (int_buffer);
X         `125  while ((int_buffer `0910`093 != 'y') && (int_buffer `0910`093
V != 'Y') &&`032
X                   (int_buffer `0910`093 != 'n') && (int_buffer `0910`093 !=
V 'N'));
X
X         if ((int_buffer `0910`093 == 'n') `124`124 (int_buffer `0910`093 ==
V 'N'))
X         `123
X            if ((status = mail$send_abort`032
X                             (&send_context,`032
X                              &mail_null_list,`032
X                              &mail_null_list)) != SS$_NORMAL)
X            `123
X#if FALSE
X               lib$signal (status);
X#endif
X               printf ("\n\n");
X            `125
X            if ((status = mail$send_end`032
X                             (&send_context,`032
X                              &mail_null_list,`032
X                              &mail_null_list)) != SS$_NORMAL)
X            `123
X#if FALSE
X               lib$signal (status);
X#endif
X               printf ("\n\n");
X            `125
X
X            /* delete the file */
+-+-+-+-+-+-+-+-  END  OF PART 8 +-+-+-+-+-+-+-+-

