mksh/mksh.logging/src.1mai/atrshmlog_internal.c
int atrshmlog_create(const key_t i_key,
          const int i_count)
{
  int result = -1;

  if (i_key == 0 || i_key  == IPC_PRIVATE)
    return result;

  --result;
  
  /* at least ATRSHMLOGBUFFER_MINCOUNT .. */
  if (i_count < ATRSHMLOGBUFFER_MINCOUNT)
    return result;

  --result;
  
  /* max ATRSHMLOGBUFFER_MAXCOUNT buffers */
  if (i_count > ATRSHMLOGBUFFER_MAXCOUNT)
    return result;

  /* we calc the buffer size.
   * its a fixed part for our infos and a variabel count of
   * buffers.
   * some systems dont have much memory for a shm buffer, 
   * some have...
   * so simply try to check for the size that is possible with the
   * double number check ...
   */
  
  size_t wantedsize = sizeof (atr_shm_log_area_t) + (i_count - ATRSHMLOGBUFFER_MINCOUNT) * sizeof( atr_shm_log_buffer_t);

  int shmflg = IPC_CREAT | IPC_EXCL;

  shmflg |= ATRSHMLOG_ACCESS; 
    
  int result_shmget = shmget(i_key, wantedsize, shmflg);

  --result;
    
  if (result_shmget == -1)
    return result;

  return result_shmget;
}
/* we create the shm 
 * on error we deliver a -x, else a valid positive shmid
 * this uses the key from external.
 * key is a 32 bit value
 */
we create the shm
on error we deliver a -x, else a valid positive shmid
this uses the key from external.
key is a 32 bit value
we create the shm on error we deliver a - x else a valid positive shmid this uses the key from external . key is a 32 bit value
int atrshmlog_create(const key_t i_key,
          const int i_count)
{
  int result = -1;
  if (i_key == 0 || i_key  == IPC_PRIVATE)
    return result;
  --result;
  if (i_count < ATRSHMLOGBUFFER_MINCOUNT)
    return result;
  --result;
  if (i_count > ATRSHMLOGBUFFER_MAXCOUNT)
    return result;
  size_t wantedsize = sizeof (atr_shm_log_area_t) + (i_count - ATRSHMLOGBUFFER_MINCOUNT) * sizeof( atr_shm_log_buffer_t);
  int shmflg = IPC_CREAT | IPC_EXCL;
  shmflg |= ATRSHMLOG_ACCESS; 
  int result_shmget = shmget(i_key, wantedsize, shmflg);
  --result;
  if (result_shmget == -1)
    return result;
  return result_shmget;
}
int atrshmlog_create ( const key_t i_key , const int i_count ) { int result = -1 ; if ( i_key == 0 || i_key == IPC_PRIVATE ) return result ; -- result ; if ( i_count < ATRSHMLOGBUFFER_MINCOUNT ) return result ; -- result ; if ( i_count > ATRSHMLOGBUFFER_MAXCOUNT ) return result ; size_t wantedsize = sizeof ( atr_shm_log_area_t ) + ( i_count - ATRSHMLOGBUFFER_MINCOUNT ) * sizeof ( atr_shm_log_buffer_t ) ; int shmflg = IPC_CREAT | IPC_EXCL ; shmflg |= ATRSHMLOG_ACCESS ; int result_shmget = shmget ( i_key , wantedsize , shmflg ) ; -- result ; if ( result_shmget == -1 ) return result ; return result_shmget ; }
we create the shm
 on error we deliver a -x, else a valid positive shmid
 this uses the key from external.
we create the shm on error we deliver a - x else a valid positive shmid this uses the key from external .
/* at least ATRSHMLOGBUFFER_MINCOUNT .. */ /* max ATRSHMLOGBUFFER_MAXCOUNT buffers */ /* we calc the buffer size.
   * its a fixed part for our infos and a variabel count of
   * buffers.
   * some systems dont have much memory for a shm buffer, 
   * some have...
   * so simply try to check for the size that is possible with the
   * double number check ...
   */