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

Received:  by crdgw1.ge.com (5.57/GE 1.76)
	 id AA01212; Wed, 14 Nov 90 06:15:49 EST
Received: From ICNUCEVM.CNUCE.CNR.IT by CRVAX.SRI.COM with TCP; Wed, 14 NOV 90 01:35:39 PST
Received: from ITOPOLI.BITNET by ICNUCEVM.CNUCE.CNR.IT (IBM VM SMTP R1.2.2MX) with BSMTP id 0274; Wed, 14 Nov 90 10:32:31 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 5 of 10
To: info-vax@kl.sri.com
Message-Id: <04DBB2BB6F3F20028A@ITOPOLI.BITNET>
X-Envelope-To: info-vax@kl.sri.com
X-Vms-To: INFOVAX

-+-+-+-+-+-+-+-+ START OF PART 5 -+-+-+-+-+-+-+-+
X      printf ("Your current group is now %s\n\n", curr_group->group_name);
X   `125
X   else
X   `123
X      curr_group = (AUTOSELECT *) NULL;
X   `125
X   curr_message = BEG_OF_MSG_LIST;
X
X   READ_COMM:
X
X   printf ("%s", PLM$MAIL_PROMPT);
X
X   /* get the command */
X   if (gets (comm_buffer) == NULL)
X   `123
X      /* control-Z */
X      mail_end ();
X      exit (SS$_NORMAL);
X   `125      `032
X
X   PARSE_COMM:
X  `032
X   for (par_offset = 0;
X        (comm_buffer `091par_offset`093 == ' ') `124`124 (comm_buffer `091pa
Vr_offset`093 == '\t');
X        par_offset++);
X   if ((comm_key = comm_buffer `091par_offset++`093) == '\0')
X      goto READ_COMM;
X   if ((comm_buffer `091par_offset`093 != ' ') &&`032
X       (comm_buffer `091par_offset`093 != '\t') &&`032
X       (comm_buffer `091par_offset`093 != '\0') &&`032
X       (comm_buffer `091par_offset`093 != '0') &&`032
X       (comm_buffer `091par_offset`093 != '1') &&`032
X       (comm_buffer `091par_offset`093 != '2') &&`032
X       (comm_buffer `091par_offset`093 != '3') &&`032
X       (comm_buffer `091par_offset`093 != '4') &&`032
X       (comm_buffer `091par_offset`093 != '5') &&`032
X       (comm_buffer `091par_offset`093 != '6') &&`032
X       (comm_buffer `091par_offset`093 != '7') &&`032
X       (comm_buffer `091par_offset`093 != '8') &&`032
X       (comm_buffer `091par_offset`093 != '9'))  `032
X   `123
X      printf ("PLM$MAIL-E-INVCOMM, Invalid command\n");
X      goto READ_COMM;
X   `125
X
X   for ( ; (comm_buffer `091par_offset`093 == ' ') `124`124`032
X           (comm_buffer `091par_offset`093 == '\t'); par_offset++);
X    `032
X   switch (comm_key)
X   `123
X      case 'a':
X      case 'A':
X         /* show automatic selection results */
X
X         printf ("\n\nSelected messages in folder %s:\n", folder_name);
X         i = 0;
X         tmp_autosel = autoselect_list;
X         while (tmp_autosel != NULL)
X         `123
X            if (tmp_autosel->selected_number)
X            `123
X               i += tmp_autosel->selected_number;
X               printf ("   %3ld in group %s\n",`032
X                       tmp_autosel->selected_number, tmp_autosel->group_name
V);
X            `125
X            tmp_autosel = tmp_autosel->next;
X         `125
X         printf ("Total number: %ld\n\n", i);
X         goto READ_COMM;
X         break;
X
X      case 'l':
X      case 'L':
X         /* list a group */
X         if (comm_buffer `091par_offset`093 == '\0')
X         `123
X            /* list the current group */
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            tmp_autosel = curr_group;
X            /* if a message is currently selected, start from it */
X            if ((curr_message != BEG_OF_MSG_LIST) &&`032
X                (curr_message != END_OF_MSG_LIST))
X               msg_dsc_ptr = curr_message;
X            else
X               msg_dsc_ptr = tmp_autosel->msg_list_ptr;
X         `125
X         else
X         `123
X            sscanf (comm_buffer + par_offset , "%s", group_name);
X            tmp_autosel = autoselect_list;
X            while ((tmp_autosel != NULL) &&`032
X                   (!strcmpnocase (tmp_autosel->group_name, group_name)))
X            `123
X               tmp_autosel = tmp_autosel->next;
X            `125
X            if (tmp_autosel == NULL)
X            `123       `032
X               printf ("PLM$MAIL-E-NOGRUP, group %s not found\n", group_name
V);
X               curr_group = (AUTOSELECT *) NULL;
X               goto READ_COMM;
X            `125
X            curr_message = BEG_OF_MSG_LIST;
X            curr_group = tmp_autosel;
X            /* start from first message */
X            msg_dsc_ptr = tmp_autosel->msg_list_ptr;
X         `125
X         printf ("\n\nMessages in group %s:\n", tmp_autosel->group_name);
X         line_cnt = 3;
X         while (msg_dsc_ptr != END_OF_MSG_LIST)
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            printf (" %3ld - %-0.20s - %-0.50s\n",`032
X                    msg_dsc_ptr->id, msg_dsc_ptr->from, msg_dsc_ptr->subject
V);
X            if (msg_dsc_ptr->extracted `124`124 msg_dsc_ptr->deleted)
X            `123
X               if (msg_dsc_ptr->extracted && msg_dsc_ptr->deleted)
X                  printf ("       (extracted, deleted)\n");
X               else
X                  if (msg_dsc_ptr->extracted)
X                     printf ("       (extracted)\n");
X                  else
X                     printf ("       (deleted)\n");
X               line_cnt++;
X            `125
X            msg_dsc_ptr = msg_dsc_ptr->next;
X            line_cnt++;
X         `125
X         printf ("Total number: %ld\n\n", tmp_autosel->selected_number);
X         goto READ_COMM;
X         break;
X
X      case 'g':
X      case 'G':
X         /* set a group as current */
X         if (comm_buffer `091par_offset`093 == '\0')
X         `123
X            printf ("PLM$MAIL-E-NOPARAM, Missing command parameter\n");
X            goto READ_COMM;
X         `125
X         sscanf (comm_buffer + par_offset , "%s", group_name);
X         tmp_autosel = autoselect_list;
X         while ((tmp_autosel != NULL) &&`032
X                (!strcmpnocase (tmp_autosel->group_name, group_name)))
X         `123
X            tmp_autosel = tmp_autosel->next;
X         `125
X         if (tmp_autosel == NULL)
X         `123
X            printf ("PLM$MAIL-E-NOGRUP, group %s not found\n", group_name);
X            goto READ_COMM;
X         `125
X         curr_group = tmp_autosel;
X         curr_message = BEG_OF_MSG_LIST;
X         goto READ_COMM;
X         break;
X
X      case 'm':
X      case 'M':
X         /* set a message as current */
X         if (comm_buffer `091par_offset`093 == '\0')
X         `123
X            printf ("PLM$MAIL-E-NOPARAM, Missing command parameter\n");
X            goto READ_COMM;
X         `125
X         if (curr_group == NULL)
X         `123`032
X            printf ("PLM$MAIL-E-NOCURRGRUP, No current group selected\n");
X            goto READ_COMM;
X         `125
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 group\n"
V);
X            goto READ_COMM;
X         `125
X         curr_message = msg_dsc_ptr;
X         goto READ_COMM;
X         break;
X
X      case '0':
X      case '1':
X      case '2':
X      case '3':
X      case '4':
X      case '5':
X      case '6':
X      case '7':
X      case '8':
X      case '9':
X         par_offset = 0;
X      case 't':
X      case 'T':
X         /* type 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         `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            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 group\
Vn");
X               goto READ_COMM;
X            `125
X            curr_message = msg_dsc_ptr;
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
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 'n':
X      case 'N':
X         /* type next message */
X         if ((curr_message == BEG_OF_MSG_LIST) `124`124
X             (curr_message == END_OF_MSG_LIST))
X         `123
X            if (curr_message == BEG_OF_MSG_LIST)
X            `123
X               /* first 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_ptr == END_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_ptr;
X            `125
X            else
X            `123
X               /* try to use next 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          `032
X  `032
X               tmp_autosel = curr_group;
X               do
X               `123
X                  tmp_autosel = tmp_autosel->next;
X                  if (tmp_autosel == NULL)
X                  `123
X                     /* start again */
X                     tmp_autosel = autoselect_list;
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",`032
X                           curr_group->group_name);
X               `125
X                 `032
X               if (curr_group->msg_list_ptr == END_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_ptr;
X            `125
X         `125
X         else
X         `123
X            curr_message = curr_message->next;
X            if (curr_message == END_OF_MSG_LIST)
X            `123
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
+-+-+-+-+-+-+-+-  END  OF PART 5 +-+-+-+-+-+-+-+-

