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

  /* we check first, then we initialize.
   * its vital that we do NOT reinitialize the buffer ! 
   */
  
  if ( ! ATRSHMLOGLOGGING )
    return result;

  atr_shm_log_area_t *a = (atr_shm_log_area_t *)atrshmlog_base_ptr;

  --result;
    
  if (a->shmid == atrshmlog_shmid())
    return result;

  --result;

  if (a->safeguard == SAFEGUARDVALUE)
    return result;
    
  /* ok. we are in. the shm seems not to be initialized */
  
  for (int i = 0; i < i_count_buffers ; i++)
    {
      int initresult = atrshmlog_init_one_buffer(ATRSHMLOGGETAREA, i);
    
      --result;
      
      if (initresult < 0)
    return result;
    }
  

  /* ok. we can now set the final info in the buffer */
  a->version = ATRSHMLOGVERSION;
  a->shmid = atrshmlog_shmid();
  a->count = i_count_buffers;
  a->lastused = 0;
  a->ich_habe_fertig = 0;
  a->readerflag = 0;
  a->readerpid = 0;
  a->writerflag = 0;
  a->writerpid = 0;
  a->safeguard = SAFEGUARDVALUE;

  return 0;
}
/* we initialize the buffer after it is attached 
 * this is not mt safe
 * so try to use a initialisation program that is
 * simple for it.
 * see the atrshmloginit.c for this
 */
we initialize the buffer after it is attached
this is not mt safe
so try to use a initialisation program that is
simple for it.
see the atrshmloginit.c for this
we initialize the buffer after it is attached this is not mt safe so try to use a initialisation program that is simple for it . see the atrshmloginit . c for this
int atrshmlog_init_shm_log (const int i_count_buffers)
{
  int result = -1;
  if ( ! ATRSHMLOGLOGGING )
    return result;
  atr_shm_log_area_t *a = (atr_shm_log_area_t *)atrshmlog_base_ptr;
  --result;
  if (a->shmid == atrshmlog_shmid())
    return result;
  --result;
  if (a->safeguard == SAFEGUARDVALUE)
    return result;
  for (int i = 0; i < i_count_buffers ; i++)
    {
      int initresult = atrshmlog_init_one_buffer(ATRSHMLOGGETAREA, i);
      --result;
      if (initresult < 0)
    return result;
    }
  a->version = ATRSHMLOGVERSION;
  a->shmid = atrshmlog_shmid();
  a->count = i_count_buffers;
  a->lastused = 0;
  a->ich_habe_fertig = 0;
  a->readerflag = 0;
  a->readerpid = 0;
  a->writerflag = 0;
  a->writerpid = 0;
  a->safeguard = SAFEGUARDVALUE;
  return 0;
}
int atrshmlog_init_shm_log ( const int i_count_buffers ) { int result = -1 ; if ( ! ATRSHMLOGLOGGING ) return result ; atr_shm_log_area_t * a = ( atr_shm_log_area_t * ) atrshmlog_base_ptr ; -- result ; if ( a -> shmid == atrshmlog_shmid ( ) ) return result ; -- result ; if ( a -> safeguard == SAFEGUARDVALUE ) return result ; for ( int i = 0 ; i < i_count_buffers ; i ++ ) { int initresult = atrshmlog_init_one_buffer ( ATRSHMLOGGETAREA , i ) ; -- result ; if ( initresult < 0 ) return result ; } a -> version = ATRSHMLOGVERSION ; a -> shmid = atrshmlog_shmid ( ) ; a -> count = i_count_buffers ; a -> lastused = 0 ; a -> ich_habe_fertig = 0 ; a -> readerflag = 0 ; a -> readerpid = 0 ; a -> writerflag = 0 ; a -> writerpid = 0 ; a -> safeguard = SAFEGUARDVALUE ; return 0 ; }
we initialize the buffer after it is attached
 this is not mt safe
 so try to use a initialisation program that is
 simple for it.
we initialize the buffer after it is attached this is not mt safe so try to use a initialisation program that is simple for it .
/* we check first, then we initialize.
   * its vital that we do NOT reinitialize the buffer ! 
   */ /* ok. we are in. the shm seems not to be initialized */ /* ok. we can now set the final info in the buffer */