mksh/mksh.logging/src.1mai/atrshmlog_internal.c
int atrshmlog_verify()
{
  int result = -1 ;

  if ( ! ATRSHMLOGLOGGING )
    return result;

  atr_shm_log_area_t * a = ATRSHMLOGGETAREA;
    
  int i = 0;

  int limit = 0;
    
  --result;
    
  if (a->shmid != atrshmlog_shmid())
    return result;

  --result;

  if (a->safeguard != SAFEGUARDVALUE)
    return result;
    
  --result;

  limit = ATRSHMLOGCUTOFFLOWBYTE(a->count);
    
  if (ATRSHMLOGCUTOFFLOWBYTE(a->lastused) >= limit)
    return result;

  --result;
    
  if (a->version != ATRSHMLOGVERSION)
    return result;
    
  for (i = 0; i < limit ; i++)
    {
      int state = ATRSHMLOGCUTOFFLOWBYTE(a->logbuffers[i].state);

      --result;
    
      if (!(state == atr_shm_log_writeable
        || state == atr_shm_log_write_halffull
        || state == atr_shm_log_full ))
    return result;
      
      --result;

      if (a->logbuffers[i].safeguard != SAFEGUARDVALUE)
    return result;

      for (int i = 0; i  < ATRSHMLOGSLOTCOUNT; i++)
    ;
      
      /* TODO: 
       * check the list of info data too 
       * perhaps we will do this in the future.
       * for now we try to be not paranoid and think
       * the content is ok if all the numbers and safguards
       * are ok...
       */
    }

  return 0;
}
/* we verify the buffer is ok.
 * we check the shmid and we check the states 
 * this can not be used in mt case, so use it only for simple checker 
 * program s
 * a basic version is alredy in the atrshmlogverify.c
 */
we verify the buffer is ok.
we check the shmid and we check the states
this can not be used in mt case, so use it only for simple checker
program s
a basic version is alredy in the atrshmlogverify.c
we verify the buffer is ok . we check the shmid and we check the states this can not be used in mt case so use it only for simple checker program s a basic version is alredy in the atrshmlogverify . c
int atrshmlog_verify()
{
  int result = -1 ;
  if ( ! ATRSHMLOGLOGGING )
    return result;
  atr_shm_log_area_t * a = ATRSHMLOGGETAREA;
  int i = 0;
  int limit = 0;
  --result;
  if (a->shmid != atrshmlog_shmid())
    return result;
  --result;
  if (a->safeguard != SAFEGUARDVALUE)
    return result;
  --result;
  limit = ATRSHMLOGCUTOFFLOWBYTE(a->count);
  if (ATRSHMLOGCUTOFFLOWBYTE(a->lastused) >= limit)
    return result;
  --result;
  if (a->version != ATRSHMLOGVERSION)
    return result;
  for (i = 0; i < limit ; i++)
    {
      int state = ATRSHMLOGCUTOFFLOWBYTE(a->logbuffers[i].state);
      --result;
      if (!(state == atr_shm_log_writeable
        || state == atr_shm_log_write_halffull
        || state == atr_shm_log_full ))
    return result;
      --result;
      if (a->logbuffers[i].safeguard != SAFEGUARDVALUE)
    return result;
      for (int i = 0; i  < ATRSHMLOGSLOTCOUNT; i++)
    ;
    }
  return 0;
}
int atrshmlog_verify ( ) { int result = -1 ; if ( ! ATRSHMLOGLOGGING ) return result ; atr_shm_log_area_t * a = ATRSHMLOGGETAREA ; int i = 0 ; int limit = 0 ; -- result ; if ( a -> shmid != atrshmlog_shmid ( ) ) return result ; -- result ; if ( a -> safeguard != SAFEGUARDVALUE ) return result ; -- result ; limit = ATRSHMLOGCUTOFFLOWBYTE ( a -> count ) ; if ( ATRSHMLOGCUTOFFLOWBYTE ( a -> lastused ) >= limit ) return result ; -- result ; if ( a -> version != ATRSHMLOGVERSION ) return result ; for ( i = 0 ; i < limit ; i ++ ) { int state = ATRSHMLOGCUTOFFLOWBYTE ( a -> logbuffers [ i ] . state ) ; -- result ; if ( ! ( state == atr_shm_log_writeable || state == atr_shm_log_write_halffull || state == atr_shm_log_full ) ) return result ; -- result ; if ( a -> logbuffers [ i ] . safeguard != SAFEGUARDVALUE ) return result ; for ( int i = 0 ; i < ATRSHMLOGSLOTCOUNT ; i ++ ) ; } return 0 ; }
we verify the buffer is ok.
 we check the shmid and we check the states
 this can not be used in mt case, so use it only for simple checker
 program s
 a basic version is alredy in the atrshmlogverify.c
we verify the buffer is ok . we check the shmid and we check the states this can not be used in mt case so use it only for simple checker program s a basic version is alredy in the atrshmlogverify . c
/* TODO: 
       * check the list of info data too 
       * perhaps we will do this in the future.
       * for now we try to be not paranoid and think
       * the content is ok if all the numbers and safguards
       * are ok...
       */