From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 14-NOV-1990 06:41:32.67
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	PLM$MAIL, part 6 of 10

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

-+-+-+-+-+-+-+-+ START OF PART 6 -+-+-+-+-+-+-+-+
X                  ("\n*** Press RETURN to continue, a command or `094Z to br
Veak *** ");
X               if (gets (int_buffer) == NULL)
X               `123
X                  /* control Z */
X                  goto READ_COMM;
X               `125      `032
X               trim (int_buffer);
X               if (int_buffer `0910`093 != '\0')
X               `123
X                  strcpy (comm_buffer, int_buffer);
X                  goto PARSE_COMM;
X               `125
X               printf ("\n\n");
X               line_cnt = 0;
X            `125 `032
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               printf ("%s\n", msg_buffer);
X               line_cnt++;
X            `125
X         `125  while (status != MAIL$_NOMOREREC);
X         printf ("\n");
X         goto READ_COMM;
X         break;
X
X      case 'p':
X      case 'P':
X         /* type previous message */
X         if ((curr_message == BEG_OF_MSG_LIST) `124`124
X             (curr_message == END_OF_MSG_LIST))
X         `123
X            if (curr_message == END_OF_MSG_LIST)
X            `123
X               /* last message in current group */
X               if (curr_group == NULL)
X               `123
X                  printf ("PLM$MAIL-E-NOCURRGRUP, No current group selected\
Vn");
X                  goto READ_COMM;
X               `125
X
X               if (curr_group->msg_list_last_ptr == BEG_OF_MSG_LIST)
X               `123
X                  printf`032
X                     ("PLM$MAIL-E-NOMSG, No message found in current group\n
V");
X                  goto READ_COMM;
X               `125
X               curr_message = curr_group->msg_list_last_ptr;
X            `125
X            else
X            `123
X               /* try to use previous group */
X               if (curr_group == NULL)
X               `123
X                  printf ("PLM$MAIL-E-NOCURRGRUP, No current group selected\
Vn");
X                  goto READ_COMM;
X               `125
X
X               tmp_autosel = curr_group;
X               do
X               `123
X                  tmp_autosel = tmp_autosel->previous;
X                  if (tmp_autosel == NULL)
X                  `123
X                     /* start again */
X                     tmp_autosel = autoselect_list_tail;
X                  `125
X               `125  while ((tmp_autosel != curr_group) &&
X                         (tmp_autosel->selected_number == 0));
X               if (tmp_autosel != curr_group)
X               `123
X                  curr_group = tmp_autosel;
X                  printf ("\n\nYour current group is now %s\n\n",`032
X                           curr_group->group_name);
X               `125
X
X               if (curr_group->msg_list_last_ptr == BEG_OF_MSG_LIST)
X               `123
X                  printf`032
X                     ("PLM$MAIL-E-NOMSG, No message found in current group\n
V");
X                  goto READ_COMM;
X               `125
X               curr_message = curr_group->msg_list_last_ptr;
X            `125
X         `125
X         else
X         `123
X            curr_message = curr_message->previous;
X            if (curr_message == BEG_OF_MSG_LIST)
X            `123                           `032
X               printf ("PLM$MAIL-E-NOMOREMSG, No more messages\n");
X               goto READ_COMM;
X            `125
X         `125
X
X         /* mark the message */
X         curr_message->read = TRUE;
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         /* type the records of the message */
X         printf ("\n\n %3d - Received: %s\n\n",`032
X                 curr_message->id, curr_message->date);
X         line_cnt = 3;
X         do
X         `123
X            if (line_cnt >= MAX_LIST_LINES)
X            `123
X               printf`032
X                  ("\n*** Press RETURN to continue, a command or `094Z to br
Veak *** ");
X               if (gets (int_buffer) == NULL)
X               `123
X                  /* control Z */
X                  goto READ_COMM;
X               `125      `032
X               trim (int_buffer);
X               if (int_buffer `0910`093 != '\0')
X               `123
X                  strcpy (comm_buffer, int_buffer);
X                  goto PARSE_COMM;
X               `125
X               printf ("\n\n");
X               line_cnt = 0;
X            `125 `032
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                                                          `0
V32
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               printf ("%s\n", msg_buffer);
X               line_cnt++;
X            `125
X         `125  while (status != MAIL$_NOMOREREC);
X         printf ("\n");
X         goto READ_COMM;
X         break;
X
X      case 'e':
X      case 'E':
X         /* extract a message */
X         if (comm_buffer `091par_offset`093 == '\0')
X         `123
X            if ((curr_message == BEG_OF_MSG_LIST) `124`124
X                (curr_message == END_OF_MSG_LIST))
X            `123
X               printf`032
X                  ("PLM$MAIL-E-NOCURRMSG, No message selected as current\n")
V;
X               goto READ_COMM;
X            `125
X            wild = FALSE;
X            group_name `0910`093 ='\0';
X         `125
X         else
X         `123
X            if (curr_group == NULL)
X            `123
X               printf ("PLM$MAIL-E-NOCURRGRUP, No current group selected\n")
V;
X               goto READ_COMM;
X            `125
X
X            /* wildcard ? */
X            group_name `0910`093 ='\0';
X            sscanf (comm_buffer + par_offset , "%s %s", int_buffer, group_na
Vme);
X            if (int_buffer `0910`093 == '*')
X            `123
X               msg_dsc_ptr = curr_group->msg_list_ptr;
X               if (msg_dsc_ptr == END_OF_MSG_LIST)
X               `123
X                  printf`032
X                    ("PLM$MAIL-E-NOMSG, No messages in current group\n");
X                  goto READ_COMM;
X               `125
X               curr_message = msg_dsc_ptr;
X               wild = TRUE;
X            `125
X            else
X            `123
X               /* message id and/or groupname */
X               wild = FALSE;
X               group_name `0910`093 ='\0';
X               sscanf (comm_buffer + par_offset , "%s %s",`032
X                       int_buffer, group_name);
X               if ((int_buffer `0910`093 < '0') `124`124 (int_buffer `0910`0
V93 > '9'))
X               `123
X                  /* group name only */
X                  strcpy (group_name, int_buffer);
X               `125
X               else
X               `123
X                  /* re-read (in decimal format) the message id */
X                  sscanf (comm_buffer + par_offset , "%d", &message_id);
X                  msg_dsc_ptr = curr_group->msg_list_ptr;
X                  while (msg_dsc_ptr != END_OF_MSG_LIST)
X                  `123
X                     if (msg_dsc_ptr->id == message_id)
X                        break;
X                     msg_dsc_ptr = msg_dsc_ptr->next;
X                  `125
X                  if (msg_dsc_ptr == END_OF_MSG_LIST)
X                  `123
X                     printf`032
X                        ("PLM$MAIL-E-MSGNOTFND, Message not found in current
V group\n");
X                     goto READ_COMM;
X                  `125
X                  curr_message = msg_dsc_ptr;
X               `125
X            `125
X         `125
X
X         /* if group name specified, find the default extraction directory *
V/
X         if (group_name `0910`093 != '\0')
X         `123
X            tmp_autosel = autoselect_list;
X            while (tmp_autosel != NULL)
X            `123
X               if (strcmpnocase (tmp_autosel->group_name, group_name))
X                  break;
X               tmp_autosel = tmp_autosel->next;
X            `125
X            if (tmp_autosel == NULL)
X            `123
X               printf ("PLM$MAIL-E-NOGROUP, Group %s not found\n", group_nam
Ve);
X               goto READ_COMM;
X            `125
X         `125
X         else
X         `123
X            tmp_autosel = curr_group;
X         `125
X
X         do
X         `123
X            if (!wild `124`124 (wild && !curr_message->deleted))
X            `123
X               /* find out the file name and the directory */
X               switch (curr_group->key_code)
X               `123
X                  case 'b':
X                     build_bigmail_filename (filename,`032
X                                             tmp_autosel->default_subdir,`03
V2
X                                             curr_message->subject);
X                     break;
X     `032
X                  default:
X                     build_message_filename (filename,`032
X                                             tmp_autosel->default_subdir,`03
V2
X                                             curr_message->subject,`032
X                                             curr_message->id);
X               `125
V                                                          `032
X     `032
X               /* ask for filename (with default) only if not wildcard */
X               if (wild)
X               `123
X                  printf ("Extracting message %d to file %s\n",`032
X                          curr_message->id, filename);
X               `125
X               else
X               `123
X                  if (curr_message->deleted)
X                  `123
X                     printf ("Warning: message #%d is marked for deletion\n"
V,`032
X                             curr_message->id);
X                  `125
X                  printf ("Filename `091 %s `093: ", filename);
X                  if (gets (int_buffer) == NULL)
X                  `123
X                     /* control Z */
X                     goto READ_COMM;
X                  `125      `032
X                  trim (int_buffer);
X                  if (int_buffer `0910`093 != '\0')
X                     strcpy (filename, int_buffer);
X               `125
X     `032
X               if ((fp = fopen (filename, "w")) == NULL)
X               `123
X                  printf`032
X                     ("PLM$MAIL-F-OPENERR, Cannot create file %s\n", filenam
Ve);
X                  goto READ_COMM;
X               `125
X     `032
X               /* mark the message */
X               curr_message->extracted = TRUE;
X               /* select the message (use get from ans subject strings items
V) */
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               /* copy into the file the records of the message */
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                     fprintf (fp, "%s\n", msg_buffer);
X                  `125
X               `125  while (status != MAIL$_NOMOREREC);
X               fclose (fp);
X            `125
X     `032
X            /* get next message, if wildcard */
X            if (wild)
X            `123
X               curr_message = curr_message->next;
X            `125
X
X         `125  while (wild && (curr_message != END_OF_MSG_LIST));
X         goto READ_COMM;
X         break;
X
X      case 'd':
X      case 'D':
X         /* delete a message */
X         if (comm_buffer `091par_offset`093 == '\0')
X         `123
X            if ((curr_message == BEG_OF_MSG_LIST) `124`124`032
X                (curr_message == END_OF_MSG_LIST))
X            `123
X               printf`032
X                  ("PLM$MAIL-E-NOCURRMSG, No message selected as current\n")
V;
X               goto READ_COMM;
X            `125
X            wild = FALSE;
X            tmp_message = curr_message;
X         `125
X         else
X         `123
X            if (curr_group == NULL)
X            `123
X               printf ("PLM$MAIL-E-NOCURRGRUP, No current group selected\n")
V;
X               goto READ_COMM;
X            `125
X
X            /* wildcard ? */
+-+-+-+-+-+-+-+-  END  OF PART 6 +-+-+-+-+-+-+-+-

