[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference csc32::consolemanager

Title:POLYCENTER Console Manager
Notice:Kits, Scans, Docs on CSC32:: as PCM$KITS:,PCM$DOCS:, PCM$SCANS:
Moderator:CSC32::BUTTERWORTH
Created:Thu Aug 06 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1541
Total number of notes:6564

1158.0. "Event-context lost or incomplete in action-rtn?" by 51336::BERGGREN (Nils Berggren,DC Sweden 876-8287) Fri Jan 19 1996 09:23

     Hi,

     we're having a problem with Polycenter Console Manager at a
     customer site here in Sweden. 

     Short description:
     ------------------
     Sometimes the event context is not complete when retreived in an 
     action-routine.
     
     
     Environment:
     ------------
     VAXstation 4000/90
     OpenVMS 6.1
     Console Manager Version: V1.6 
     PCM Image file identifications gives: "V1.6-110"


     Problem description:
     --------------------
     
     I've written an Action Routine to extract event-information.
     This information is then used to generate DECmcc events, which
     are sent to some DECmcc-stations to notify an operator about some
     alarm-condition.
     
     Quite often, the action-routine doesn't get the event-context
     (using the CMGetEventContext() routine), or sometimes just a part
     of a context-line is returned.

     The Action-routine first calls CMGetEventContext() to retreive
     the number of context-lines.  If this is less than then count
     expected (as given by the CMEventCount() routine) the action
     sleeps in a loop upto 15 seconds, and then the action-routine
     proceeds anyway.  Then all the information is dumped into a
     logfile.
     
     Sometimes when CMGetEventContext() returns the same value as
     CMEventCount(), i.e.  we should have all the context-lines, the
     routine CMEventContextLine() retuns a NULL-pointer or not the
     complete context-line.
     
     
     Attached is the source-code for the action-routine as well as
     logs for 10 events showing the problem.
     
     In the logs, for each event, I've just copied the contents of the
     file created by the action-routine and appended the text
     displayed in the Console Mgr Multi Line window.

	best regards,
	Nils Berggren,
	Digital Consulting, Sweden
     

--------------------------   PCM_ACTION.C  ------------------------------------
/*
****************************************
** Facility: PCM_ACTION.C
** 
** Description:  Actionroutine for PCM.
**
** Modification History:
** 96-01-19    N Berggren	created module
****************************************
*/

/*
**  include files
*/
#include <console.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>

#include <brkdef.h>
#include <DESCRIP.h>
#include <lib$routines.h>
#include <starlet.h>
#include <ssdef.h>
#include <signal.h>

#define LOG_FILE         "users:[berggren.pcm.action_rtn]bug.log"

/*
** global variables
*/
CMContext   Context;


/*
************************************************************************
*/
void error_cb()
{
    fprintf(stderr, "BUG_ACTION: Error received.\n");
    fprintf(stderr, "BUG_ACTION: Shut down...\n");
    CMUserShutdown(&Context);
    exit(1);
}


/*
************************************************************************
*/
void event_received_cb(CMEvent event)
{
   char ascii_time[256],
        log_ascii_time[256],
        current_ascii_time[30],
	eventfilename[256],
	*dirname,
	*context_line,
	temp_str[256];

   int timesize,
       cntx_count,
       context_line_len,
       i;

   time_t  current_time;
	 
   const tm_t *ltime;

   FILE *eventfile,
        *logfile;
	  


 char	*event_name;
 char	*event_class;
 char	*event_info;
 char	*event_text;
 int	event_context;
 time_t	*event_time;
 int	event_type;
 time_t	*event_logtime;
 int	event_count;
 int	event_priority;
 char	*event_source;
 int	event_start;
 char	*event_subsystem;
 char	*event_host;
 char	*event_system;
 char	*event_userdata;
 
 int 	status;



   /*
   ** get all event-parameters.
   */


   event_name	   = CMEventName ( event );
   event_class	   = CMEventClass ( event );
   event_info	   = CMEventInfo ( event );
   event_text	   = CMEventText ( event );
   event_context   = CMEventContext ( event );
   event_time	   = CMEventTime ( event );

   event_type	   = CMEventType ( event );

   event_logtime   = CMEventLogtime ( event );
   event_count	   = CMEventCount ( event );
   event_priority  = CMEventPriority ( event );
   event_source	   = CMEventSource ( event );
   event_start	   = CMEventStart ( event );
   event_subsystem = CMEventSubSystem ( event );
   event_host	   = CMEventHost ( event );
   event_system    = CMEventSystem ( event );
   event_userdata  = CMEventUserdata ( event );

   /* Convert the time into human readable form      */

   timesize = strftime(ascii_time,
                       sizeof(ascii_time),
		       "%a %b %d %Y %H:%M:%S.%D",
		       localtime(event_time) );

		       
   current_time = time(&current_time);
   ltime = localtime( &current_time );

   strcpy(current_ascii_time, asctime( ltime));

   current_ascii_time[strlen(current_ascii_time)-1] = 0;  /* skip \n */


   if (strcmp(CMEventName(event), CMEventNameShutdown) == 0)
   {
      fprintf(stderr, "SHUTDOWN event received. Shutting down...\n");
      CMUserShutdown(&Context);
      exit(1);
   }


   /* get the context  linecount */
   event_context = CMGetEventContext(event);


   /*
   ** if we haven't got all the context-lines, wait some time (max 15 secs)....
   */
   for ( i=0; i<15 && event_context != event_count; i++) {
	sleep(1);
        event_context = CMGetEventContext(event);
   }
   

   /*
   ** log the event
   */
   if (!  (eventfile = fopen(LOG_FILE,"w")) ) {
      fprintf(stderr, "Can't open log-file %s\n",eventfilename);
      CMUserShutdown(&Context);
      exit(1);
   }
   
   

   /*
   ** write all event-data into log-file
   */
   fprintf(eventfile, "Event received at %s.\n",  current_ascii_time);

   /*
   ** log if we've waited for the event-context
   */
   if (i>0) {
	fprintf(eventfile, "\t Waited %d seconds for Context.\n",  i);
   }

   fprintf(eventfile, "\t Name:      %s\n",  event_name ? event_name : "No event_name");
   fprintf(eventfile, "\t Class:     %s\n",  event_class ? event_class : "No event_class");
   fprintf(eventfile, "\t Text:      %s\n",  event_text ? event_text : "No event_text");
   fprintf(eventfile, "\t Info:      %s\n",  event_info ? event_info : "No event_info");
   fprintf(eventfile, "\t Context:   %d\n",  event_context);
   fprintf(eventfile, "\t Time:      %s\n",  ascii_time);
   fprintf(eventfile, "\t Type:      %d\n",  event_type);
   fprintf(eventfile, "\t Count:     %d\n",  event_count);
   fprintf(eventfile, "\t Priority:  %d\n",  event_priority);
   fprintf(eventfile, "\t Source:    %s\n",  event_source ? event_source : "No event_source");
   fprintf(eventfile, "\t Start:     %d\n",  event_start);
   fprintf(eventfile, "\t Subsystem: %s\n",  event_subsystem ? event_subsystem : "No event_subsystem");
   fprintf(eventfile, "\t Host:      %s\n",  event_host ? event_host : "No event_host");
   fprintf(eventfile, "\t System:    %s\n",  event_system ? event_system : "No event_system");
   fprintf(eventfile, "\t Userdata:  %s\n",  event_userdata ? event_userdata : "No event_userdata");

   for (i=0; i<event_count+1; i++) {
      context_line = CMEventContextLine( event, i);
      context_line_len = CMEventContextLineLength( event, i);

      /*
      ** if last char before newline is <CR>, skip it.  We don't want
      ** extra <CR>'s in the logfile
      */
      if ( context_line_len > 1 &&
           context_line[ context_line_len-1] == '\n' &&
	   context_line[ context_line_len-2] == '\r' )
      {
           context_line[ context_line_len-2] = '\0';
  	   context_line_len -= 2;
      }

      /*
      ** if we get NULL back, write it out
      */
      if (context_line) {
          fprintf(eventfile, "Ctx[%2d] (%3d chars)\n|%s|\n",
      		          i,
			  context_line_len,
			  context_line ? context_line :
                                        "<NoEventContext>");
      }
      else {
          fprintf(eventfile, "Ctx[%2d] (%3d chars)\n%s\n",
      		          i,
			  context_line_len,
                          "<NoEventContext>");
      }
   }

   fclose(eventfile);

   CMFreeEventContext( event );

   /* Free the event as we have finished with it      */

   CMFreeEvent(event);

}

/*
************************************************************************
*/

/*******************
**   main entry   **
*******************/

main(argc, argv)
     int  argc;
     char *argv[];
{
    int    status,
           i;
    char *action_name = NULL;
    FILE *logfile = NULL;



    status = CMUserInit(&Context, event_received_cb, error_cb, NULL);

    if (status == CM_NORMAL) {
	CMUserMainLoop(Context);   
    }
    else {
       fprintf(stdout, "TELIA_ACTION:: Failed to initialize link with ENS\n");
    }

    exit;
    
} /* main */

--------------------------  LOGS FROM THE ACTION-ROUTINE   --------------------

Here's a log showing the PCM problem.
10 Events have be processed by the action-routine and the corresponding 
text from the Multi-Line Window (when double-clicking on an event) has 
been added.

		-*-*-*-*-*-*-*  event #1   -*-*-*-*-*-*-*  

Event received at Fri Jan 19 12:05:37 1996.
	 Name:      DCP_5_16
	 Class:     
	 Text:      CLASS=5 EVCD=16
	 Info:      DCP �vervakning SNA-Problem
	 Context:   5
	 Time:      Fri Jan 19 1996 12:05:34.
	 Type:      1
	 Count:     5
	 Priority:  2
	 Source:    Console
	 Start:     0
	 Subsystem: 
	 Host:      kcd
	 System:    kcd
	 Userdata:  UserData Not Used
Ctx[ 0] (  0 chars)
<NoEventContext>
Ctx[ 1] ( 55 chars)
|>CENL: 12:03:50 NODE=KCD      SEQ=14293 CLASS=5 EVCD=16|
Ctx[ 2] (  1 chars)
|>|
Ctx[ 3] ( 72 chars)
|>|
Ctx[ 4] (  1 chars)
|>|
Ctx[ 5] (  0 chars)
<NoEventContext>
          ==========  contents from PCM Event Window ==========
>CENL: 12:03:50 NODE=KCD      SEQ=14293 CLASS=5 EVCD=16 
> 
>       SNA:00438:SS_NAU: Unable to locate queued session YEA =    12    
> 
>CENL: 12:06:28 NODE=KCD      SEQ=14294 CLASS=13 EVCD=3 


		-*-*-*-*-*-*-*  event #2   -*-*-*-*-*-*-*  

Event received at Fri Jan 19 12:05:34 1996.
	 Waited 3 seconds for Context.
	 Name:      DCP_13_2
	 Class:     
	 Text:      CLASS=13 EVCD=2
	 Info:      DCP �vervakning LDS. MAX RESPONSE TIMEOUTS
	 Context:   5
	 Time:      Fri Jan 19 1996 12:05:33.
	 Type:      1
	 Count:     5
	 Priority:  3
	 Source:    Console
	 Start:     0
	 Subsystem: 
	 Host:      ham
	 System:    ham
	 Userdata:  UserData Not Used
Ctx[ 0] (  0 chars)
<NoEventContext>
Ctx[ 1] ( 53 chars)
|>CENL: 12:07:10 NODE=HAM      SEQ=837 CLASS=13 EVCD=2|
Ctx[ 2] ( 64 chars)
|>      LINE=MA005    DEVICE=SG$00056 PPID=13/2 HEX DEV-ID=C100 |
Ctx[ 3] ( 40 chars)
|>      EVENT/ERROR DETECTED AT L2 (LINK)|
Ctx[ 4] ( 56 chars)
|>|
Ctx[ 5] ( 67 chars)
|>1996/01/19 12:07:11 *** NODE= HAM  -- BSC 3270 Printer:  SP43     |
          ==========  contents from PCM Event Window ==========
>CENL: 12:07:10 NODE=HAM      SEQ=837 CLASS=13 EVCD=2 
>      LINE=MA005    DEVICE=SG$00056 PPID=13/2 HEX DEV-ID=C100   
>      EVENT/ERROR DETECTED AT L2 (LINK) 
>       (UDLC): OUTPUT MESSAGE TIMER TIMEOUT - RETRYABLE 
>1996/01/19 12:07:11 *** NODE= HAM  -- BSC 3270 Printer:  SP43      


		-*-*-*-*-*-*-*  event #3   -*-*-*-*-*-*-*  

Event received at Fri Jan 19 12:05:13 1996.
	 Waited 15 seconds for Context.
	 Name:      DCP_5_16
	 Class:     
	 Text:      CLASS=5 EVCD=16
	 Info:      DCP �vervakning SNA-Problem
	 Context:   2
	 Time:      Fri Jan 19 1996 12:05:12.
	 Type:      1
	 Count:     5
	 Priority:  2
	 Source:    Console
	 Start:     0
	 Subsystem: 
	 Host:      kco
	 System:    kco
	 Userdata:  UserData Not Used
Ctx[ 0] (  0 chars)
<NoEventContext>
Ctx[ 1] ( 55 chars)
|>CENL: 12:08:08 NODE=KCO      SEQ=51252 CLASS=5 EVCD=16|
Ctx[ 2] (  0 chars)
<NoEventContext>
Ctx[ 3] (  0 chars)
<NoEventContext>
Ctx[ 4] (  0 chars)
<NoEventContext>
Ctx[ 5] (  0 chars)
<NoEventContext>
          ==========  contents from PCM Event Window ==========
>CENL: 12:08:08 NODE=KCO      SEQ=51252 CLASS=5 EVCD=16 
> 
>       SNA:00438:SS_NAU: Unable to locate queued session YEA =    12    
> 
>CENL: 12:08:41 NODE=KCO      SEQ=51253 CLASS=5 EVCD=16 


		-*-*-*-*-*-*-*  event #4   -*-*-*-*-*-*-*  

Event received at Fri Jan 19 12:05:08 1996.
	 Waited 4 seconds for Context.
	 Name:      DCP_5_16
	 Class:     
	 Text:      CLASS=5 EVCD=16
	 Info:      DCP �vervakning SNA-Problem
	 Context:   5
	 Time:      Fri Jan 19 1996 12:05:07.
	 Type:      1
	 Count:     5
	 Priority:  2
	 Source:    Console
	 Start:     0
	 Subsystem: 
	 Host:      kco
	 System:    kco
	 Userdata:  UserData Not Used
Ctx[ 0] (  0 chars)
<NoEventContext>
Ctx[ 1] ( 55 chars)
|>CENL: 12:08:04 NODE=KCO      SEQ=51251 CLASS=5 EVCD=16|
Ctx[ 2] (  1 chars)
|>|
Ctx[ 3] ( 72 chars)
|>|
Ctx[ 4] (  1 chars)
|>|
Ctx[ 5] ( 55 chars)
|>CENL: 12:08:08 NODE=KCO      SEQ=51252 CLASS=5 EVCD=16|
          ==========  contents from PCM Event Window ==========
>CENL: 12:08:04 NODE=KCO      SEQ=51251 CLASS=5 EVCD=16 
> 
>       SNA:00438:SS_NAU: Unable to locate queued session YEA =    12    
> 
>CENL: 12:08:08 NODE=KCO      SEQ=51252 CLASS=5 EVCD=16 


		-*-*-*-*-*-*-*  event #5   -*-*-*-*-*-*-*  

Event received at Fri Jan 19 12:04:30 1996.
	 Name:      DCP_5_16
	 Class:     
	 Text:      CLASS=5 EVCD=16
	 Info:      DCP �vervakning SNA-Problem
	 Context:   5
	 Time:      Fri Jan 19 1996 12:04:29.
	 Type:      1
	 Count:     5
	 Priority:  2
	 Source:    Console
	 Start:     0
	 Subsystem: 
	 Host:      kco
	 System:    kco
	 Userdata:  UserData Not Used
Ctx[ 0] (  0 chars)
<NoEventContext>
Ctx[ 1] ( 55 chars)
|>CENL: 12:07:26 NODE=KCO      SEQ=51250 CLASS=5 EVCD=16|
Ctx[ 2] (  1 chars)
|>|
Ctx[ 3] ( 72 chars)
|>|
Ctx[ 4] (  1 chars)
|>|
Ctx[ 5] (  0 chars)
<NoEventContext>
          ==========  contents from PCM Event Window ==========
>CENL: 12:07:26 NODE=KCO      SEQ=51250 CLASS=5 EVCD=16 
> 
>       SNA:00438:SS_NAU: Unable to locate queued session YEA =    12    
> 
>CENL: 12:08:04 NODE=KCO      SEQ=51251 CLASS=5 EVCD=16 


		-*-*-*-*-*-*-*  event #6   -*-*-*-*-*-*-*  

Event received at Fri Jan 19 12:03:56 1996.
	 Waited 8 seconds for Context.
	 Name:      DCP_5_16
	 Class:     
	 Text:      CLASS=5 EVCD=16
	 Info:      DCP �vervakning SNA-Problem
	 Context:   5
	 Time:      Fri Jan 19 1996 12:03:55.
	 Type:      1
	 Count:     5
	 Priority:  2
	 Source:    Console
	 Start:     0
	 Subsystem: 
	 Host:      kcd
	 System:    kcd
	 Userdata:  UserData Not Used
Ctx[ 0] (  0 chars)
<NoEventContext>
Ctx[ 1] ( 55 chars)
|>CENL: 12:02:11 NODE=KCD      SEQ=14291 CLASS=5 EVCD=16|
Ctx[ 2] (  1 chars)
|>|
Ctx[ 3] ( 72 chars)
|>|
Ctx[ 4] (  1 chars)
|>|
Ctx[ 5] (  0 chars)
<NoEventContext>
          ==========  contents from PCM Event Window ==========
>CENL: 12:02:11 NODE=KCD      SEQ=14291 CLASS=5 EVCD=16 
> 
>       SNA:00438:SS_NAU: Unable to locate queued session YEA =    12    
>1996/01/19 12:02:52 *** NODE= KCD  -- BSC 3270 Printer:  KG75      
>                      PPID: 58    CUDA: C1C9    S/S Code: 4050  


		-*-*-*-*-*-*-*  event #7   -*-*-*-*-*-*-*  

Event received at Fri Jan 19 12:03:31 1996.
	 Waited 4 seconds for Context.
	 Name:      DCP_5_16
	 Class:     
	 Text:      CLASS=5 EVCD=16
	 Info:      DCP �vervakning SNA-Problem
	 Context:   5
	 Time:      Fri Jan 19 1996 12:03:25.
	 Type:      1
	 Count:     5
	 Priority:  2
	 Source:    Console
	 Start:     0
	 Subsystem: 
	 Host:      kcd
	 System:    kcd
	 Userdata:  UserData Not Used
Ctx[ 0] (  0 chars)
<NoEventContext>
Ctx[ 1] ( 55 chars)
|>CENL: 12:01:41 NODE=KCD      SEQ=14290 CLASS=5 EVCD=16|
Ctx[ 2] (  0 chars)
||
Ctx[ 3] (  0 chars)
||
Ctx[ 4] (  0 chars)
||
Ctx[ 5] (  0 chars)
<NoEventContext>
          ==========  contents from PCM Event Window ==========
>CENL: 12:01:41 NODE=KCD      SEQ=14290 CLASS=5 EVCD=16 
> 
>       SNA:00438:SS_NAU: Unable to locate queued session YEA =    12    
> 
>CENL: 12:02:11 NODE=KCD      SEQ=14291 CLASS=5 EVCD=16 


		-*-*-*-*-*-*-*  event #8   -*-*-*-*-*-*-*  

Event received at Fri Jan 19 12:03:20 1996.
	 Waited 15 seconds for Context.
	 Name:      DCP_5_16
	 Class:     
	 Text:      CLASS=5 EVCD=16
	 Info:      DCP �vervakning SNA-Problem
	 Context:   2
	 Time:      Fri Jan 19 1996 12:03:20.
	 Type:      1
	 Count:     5
	 Priority:  2
	 Source:    Console
	 Start:     0
	 Subsystem: 
	 Host:      kco
	 System:    kco
	 Userdata:  UserData Not Used
Ctx[ 0] (  0 chars)
<NoEventContext>
Ctx[ 1] ( 55 chars)
|>CENL: 12:06:16 NODE=KCO      SEQ=51247 CLASS=5 EVCD=16|
Ctx[ 2] (  0 chars)
<NoEventContext>
Ctx[ 3] (  0 chars)
<NoEventContext>
Ctx[ 4] (  0 chars)
<NoEventContext>
Ctx[ 5] (  0 chars)
<NoEventContext>
          ==========  contents from PCM Event Window ==========
>CENL: 12:06:16 NODE=KCO      SEQ=51247 CLASS=5 EVCD=16 
> 
>       SNA:00438:SS_NAU: Unable to locate queued session YEA =    12    
> 
>CENL: 12:07:26 NODE=KCO      SEQ=51250 CLASS=5 EVCD=16


		-*-*-*-*-*-*-*  event #9   -*-*-*-*-*-*-*  

Event received at Fri Jan 19 12:03:14 1996.
	 Waited 5 seconds for Context.
	 Name:      DCP_5_16
	 Class:     
	 Text:      CLASS=5 EVCD=16
	 Info:      DCP �vervakning SNA-Problem
	 Context:   5
	 Time:      Fri Jan 19 1996 12:03:13.
	 Type:      1
	 Count:     5
	 Priority:  2
	 Source:    Console
	 Start:     0
	 Subsystem: 
	 Host:      kco
	 System:    kco
	 Userdata:  UserData Not Used
Ctx[ 0] (  0 chars)
<NoEventContext>
Ctx[ 1] ( 55 chars)
|>CENL: 12:06:10 NODE=KCO      SEQ=51246 CLASS=5 EVCD=16|
Ctx[ 2] (  1 chars)
|>|
Ctx[ 3] ( 72 chars)
|>|
Ctx[ 4] (  1 chars)
|>|
Ctx[ 5] ( 55 chars)
|>CENL: 12:06:16 NODE=KCO      SEQ=51247 CLASS=5 EVCD=16|
          ==========  contents from PCM Event Window ==========
>CENL: 12:06:10 NODE=KCO      SEQ=51246 CLASS=5 EVCD=16 
> 
>       SNA:00438:SS_NAU: Unable to locate queued session YEA =    12    
> 
>CENL: 12:06:16 NODE=KCO      SEQ=51247 CLASS=5 EVCD=16 


		-*-*-*-*-*-*-*  event #10   -*-*-*-*-*-*-*  

Event received at Fri Jan 19 12:03:05 1996.
	 Name:      DCP_13_2
	 Class:     
	 Text:      CLASS=13 EVCD=2
	 Info:      DCP �vervakning LDS. MAX RESPONSE TIMEOUTS
	 Context:   5
	 Time:      Fri Jan 19 1996 12:03:03.
	 Type:      1
	 Count:     5
	 Priority:  3
	 Source:    Console
	 Start:     0
	 Subsystem: 
	 Host:      ham
	 System:    ham
	 Userdata:  UserData Not Used
Ctx[ 0] (  0 chars)
<NoEventContext>
Ctx[ 1] ( 53 chars)
|>CENL: 12:04:39 NODE=HAM      SEQ=836 CLASS=13 EVCD=2|
Ctx[ 2] ( 64 chars)
|>      LINE=MA005    DEVICE=SG$00056 PPID=13/2 HEX DEV-ID=C100 |
Ctx[ 3] ( 40 chars)
|>      EVENT/ERROR DETECTED AT L2 (LINK)|
Ctx[ 4] ( 56 chars)
|>|
Ctx[ 5] (  1 chars)
|>|
          ==========  contents from PCM Event Window ==========
>CENL: 12:04:39 NODE=HAM      SEQ=836 CLASS=13 EVCD=2 
>      LINE=MA005    DEVICE=SG$00056 PPID=13/2 HEX DEV-ID=C100   
>      EVENT/ERROR DETECTED AT L2 (LINK) 
>       (UDLC): OUTPUT MESSAGE TIMER TIMEOUT - RETRYABLE 
>1996/01/19 12:05:38 *** NODE= HAM  -- BSC 3270 Printer:  F243
T.RTitleUserPersonal
Name
DateLines
1158.129067::BUTTERWORTHGun Control is a steady hand.Fri Jan 19 1996 18:0432
    Nils,
      First of all, the problem with the NULL pointer has been fixed.
    The problem was that the Getcontext routine checked all lines but the
    last one to see if it had been successfully read. Now, the other
    problem is a simple matter of timing. There is no way to guarentee
    that *all* of the context is available when you call the routine. If
    the buffers have not been flushed to the disk then you may not get the
    whole record. Typically what I do is check the returned line count and
    if the count doesn't match I'll sleep 2 or 3 seconds and try again. Do
    this for about 10 times and *usually* all the lines will be there. With
    the bug fixed in the API the only line that may not be complete will
    be the last line of context. One other trick you can do is to increment 
    the CMEventCount(event) field by 1 before calling the CMGetEventContext 
    routine. When the return value matches the incremented CMEventCount(event)
    field you know that you have all of your lines of context because we
    really aren't interested in the last line!
    
    Now, the fix for the bug can be had one of two ways:
    
    1. I can send you the object module CSUAPI.OBJ for replacement in
    CONSOLE$LIB.OLB
    
    2. You can try out the "field test" version of ECO2 which may be had at
    
    DUMPS:[BUTTERWORTH.PCM]
    
    Note these are *savesets* and not kits so you have to install them
    manually. There is a file fo restore comamnds for the BCK's within the
    same dir.
    
    Regs,
      Dan
1158.2Not a timing-problem51336::BERGGRENNils Berggren,DC Sweden 876-8287Mon Jan 22 1996 01:4131
>    Nils,
>      First of all, the problem with the NULL pointer has been fixed.
>    The problem was that the Getcontext routine checked all lines but the
>    last one to see if it had been successfully read. Now, the other

	That's good news.  I'll try it out.

>    Now, the other
>    problem is a simple matter of timing. There is no way to guarentee
>    that *all* of the context is available when you call the routine. If
>    the buffers have not been flushed to the disk then you may not get the
>    whole record. Typically what I do is check the returned line count and
>    if the count doesn't match I'll sleep 2 or 3 seconds and try again. Do
>    this for about 10 times and *usually* all the lines will be there. With
 
	Well, as said in .0, I do just that, i.e. wait for the whole record 
	(look at event #2 in the log, "Waited 3 seconds for Context.")
	but the problem I have, is that sometimes I get truncated lines.
	
	Look at the log for event #1  (in note .0) :  cntx[3] is said to
	be 72 characters long (as returned by CMEventContextLineLength() ) 
	but only one (1) character is returned by CMEventContextLine().
	
	Event #4 shows that all the context is present, since the 5:th 
	context line is returned OK, but the 3:rd is lost...

	
	regards,
	Nils

1158.329067::BUTTERWORTHGun Control is a steady hand.Mon Jan 22 1996 15:187
    Ah!!! There is one other thing. The data you get back is rather "raw"
    and may contain NULLS, CR, LF's etc. This will make the C rtl routines
    not do what you expect. I use a stripper that blanks out all CR, LF's
    and NULLs. Try that and you'll see better results.
    
    Regs,
      Dn
1158.4.3 really made it. Thanks!51336::BERGGRENNils Berggren,DC Sweden 876-8287Tue Jan 23 1996 10:0116
      Dan,

      Thanks for the .3 reply, that really solved the problem.
      
      Now I do a:
        
	  for (i=0; i<context_line_length; i++)
	     putc( ctx_line[i], logfile);

      and now I get all the information I expect.
      
      Thanks again!
      
      regards,
      Nils Berggren
1158.529067::BUTTERWORTHGun Control is a steady hand.Tue Jan 23 1996 14:1310
    Nils,
      One comment here. Context lines are numbered starting at 1 so you
    need to modify your "for" loop. The 0th array element is used for a
    couple things internally so there is no need to strip it. V1.5 numbered
    them starting at 0 and the change was doumented in the V1.6 release
    notes just so you know.
    
    
    Regs,
      Dan
1158.6re .5 THANKS!51336::BERGGRENNils Berggren,DC Sweden 876-8287Thu Jan 25 1996 02:5714
	

	re .5

	Thanks for the comment.  I didn't know (haven't read the 
	realese notes...) and thought this was some kind of bug, since
	the docs says it starts from 0.
	
	Thanks again.
	
	/Nils