C/C++ example calls to CEEMOUT, CEENCOD, CEEMGET, CEEDCOD, and CEEMSG

/*Module/File Name:  EDCMSGS  */
 /************************************************************
 **                                                          *
 **FUNCTION  : CEEMOUT - dispatch a message to message file  *
 **          : CEENCOD - construct a condition token         *
 **          : CEEMGET - retrieve, format and store a message*
 **          : CEEDCOD - decode an existing condition token  *
 **          : CEEMSG  - retrieve, format, and dispatch a    *
 **          :         - message to message file             *
 **                                                          *
 **   This example illustrates the invocation of the         *
 **   Language Environment message and condition handling    *
 **   services.                                              *
 **   It contructs a conditon token, retrieves the associated*
 **   message, and outputs the message to the message file.  *
 **                                                          *
 **   This example program outputs the Language Environment  *
 **   message,"CEE0260S".                                    *
 **                                                          *
 *************************************************************/
#include <string.h>
#include <stdio.h>
#include <leawi.h>
#include <stdlib.h>
#include <ceeedcct.h>


int main(void) {

  _VSTRING message;
  _INT4 dest,msgindx;
  _CHAR80 msgarea;
  _FEEDBACK fc,token;
  _INT2 c_1,c_2,cond_case,sev,control;
  _CHAR3 facid;
  _INT4 isi;

  printf ( "\n**********************************\n");
  printf ( "\nCE92MSG C Example is now in motion\n");
  printf ( "\n**********************************\n");

  strcpy(message.string,"The following message, CEE0260S, is expected");
  message.length = strlen(message.string);
  dest = 2;

  /*************************************************************
   *   Call CEEMOUT to output informational message.           *
   *   Call CEEMSG to output error message if CEEMOUT fails.   *
   ************************************************************/

  CEEMOUT(&message,&dest,&fc);

  if ( _FBCHECK (fc , CEE000) != 0 ) {
     /* put the message if CEEMOUT failed */
     dest = 2;
     CEEMSG(&fc,&dest,NULL);
     exit(2999);
  }/******************************************
   * Construct a token for CEE message 0260.*
   ******************************************/
  c_1 = 3;
  c_2 = 260;
  cond_case = 1;
  sev = 3;
  control = 1;
  memcpy(facid,"CEE",3);
  isi = 0;

  CEENCOD(&c_1,&c_2,&cond_case,&sev,&control,
          facid,&isi,&token,&fc);
  if ( _FBCHECK ( fc , CEE000 ) != 0 ) {
     printf("CEENCOD failed with message number %d\n",
            fc.tok_msgno);
     exit(2999);
  }

  /******************************************
   * Initialize the message area.           *
   ******************************************/
  msgindx = 0;
  memset(msgarea,' ',79);
  msgarea[80] = '\0';

  /****************************************************************
   * Use CEEMGET until all the message has been retrieved.        *
   * Msgindx will be zero when all the message has been retrieved.*
   * Call CEEMSG to output error message if CEEMGET fails.        *
   ****************************************************************/
  do {
     CEEMGET(&token,msgarea,&msgindx,&fc);

     if (fc.tok_sev > 1) {
        dest = 2;
        CEEMSG(&fc,&dest,NULL);
        exit(2999);
     }
     memcpy(message.string,msgarea,80);
     message.length = 80;
     dest = 2;

     CEEMOUT(&message,&dest,&fc);          /* put out the message */

     if ( _FBCHECK (fc , CEE000) != 0 ) {
        dest = 2;
        CEEMSG(&fc,&dest,NULL);
        exit(2999);
     }
  } while (msgindx != 0);
  printf ( "\n**********************************\n");
  printf ( "\nCE92MSG C Example is now ended    \n");
  printf ( "\n**********************************\n");
}