FreeBSD/sys/dev/pms/freebsd/driver/common/lxosapi.c
/******************************************************************************
ostiMakeParamString()
Purpose:
  Utility function to simplify flow in ostiGetTransportParam().  Produces
  a string handle constructed from ostiGetTransportParam() values:
  key, subkey1, subkey2, subkey3, subkey4, subkey5, and valueName.
Parameters:
  S08 *aKey (IN)             Pointer to 1st level parameter string
  S08 *aSubkey1 (IN)         Pointer to 2nd level parameter string
  S08 *aSubkey2 (IN)         Pointer to 3rd level parameter string
  S08 *aSubkey3 (IN)         Pointer to 4th level parameter string
  S08 *aSubkey4 (IN)         Pointer to 5th level parameter string
  S08 *aSubkey5 (IN)         Pointer to 6th level parameter string
  S08 *aValueName (IN)       Pointer to name string of the value under keys
  S08 *aFullKey (OUT)        Pointer to returned key-value-handle buffer
  U32 *apLenFullKey (OUT)    String length in the key-value-handle buffer
Return:
  tiSuccess - Success
  tiError   - Failed
Note:
  If all input strings are NULL, tiError will return with zero in apLenFullKey
*****************************************************************************/
ostiMakeParamString()
Purpose:
Utility function to simplify flow in ostiGetTransportParam().  Produces
a string handle constructed from ostiGetTransportParam() values:
key, subkey1, subkey2, subkey3, subkey4, subkey5, and valueName.
ostiMakeParamString () Purpose : Utility function to simplify flow in ostiGetTransportParam () . Produces a string handle constructed from ostiGetTransportParam () values : key subkey1 subkey2 subkey3 subkey4 subkey5 and valueName .
inline static U32 ostiMakeParamString( S08 *aKey,
                                       S08 *aSubkey1,
                                       S08 *aSubkey2,
                                       S08 *aSubkey3,
                                       S08 *aSubkey4,
                                       S08 *aSubkey5,
                                       S08 *aValueName,
                                       S08 *aFullKey,
                                       U32 *apLenFullKey )
{
  if( agNULL == aKey ) {
    *apLenFullKey = 0;
    printf( "ostiGetTransportParam called with no key.  how odd.\n" );
    return tiError;
  }
  if( agNULL == aValueName ) {
    *apLenFullKey = 0;
    printf( "ostiGetTransportParam called with no value-name.  how odd.\n" );
    return tiError;
  }
  strcpy( aFullKey, "DPMC_" );  
  strcat( aFullKey, aKey );
  int lIdx;
  S08 *lStrIdx = agNULL;
  for( lIdx = 1; lIdx <= 5; lIdx++ ) {
    if( 1 == lIdx) lStrIdx = aSubkey1;
    if( 2 == lIdx) lStrIdx = aSubkey2;
    if( 3 == lIdx) lStrIdx = aSubkey3;
    if( 4 == lIdx) lStrIdx = aSubkey4;
    if( 5 == lIdx) lStrIdx = aSubkey5;
    if( agNULL == lStrIdx ) break; 
    strcat( aFullKey, "_" );
    strcat( aFullKey, lStrIdx );
  }
  strcat( aFullKey, "_" );
  strcat( aFullKey, aValueName );
  *apLenFullKey = strlen( aFullKey ); 
  return tiSuccess; 
}
inline static U32 ostiMakeParamString ( S08 * aKey , S08 * aSubkey1 , S08 * aSubkey2 , S08 * aSubkey3 , S08 * aSubkey4 , S08 * aSubkey5 , S08 * aValueName , S08 * aFullKey , U32 * apLenFullKey ) { if ( agNULL == aKey ) { * apLenFullKey = 0 ; printf ( " \n " ) ; return tiError ; } if ( agNULL == aValueName ) { * apLenFullKey = 0 ; printf ( " \n " ) ; return tiError ; } strcpy ( aFullKey , " " ) ; strcat ( aFullKey , aKey ) ; int lIdx ; S08 * lStrIdx = agNULL ; for ( lIdx = 1 ; lIdx <= 5 ; lIdx ++ ) { if ( 1 == lIdx ) lStrIdx = aSubkey1 ; if ( 2 == lIdx ) lStrIdx = aSubkey2 ; if ( 3 == lIdx ) lStrIdx = aSubkey3 ; if ( 4 == lIdx ) lStrIdx = aSubkey4 ; if ( 5 == lIdx ) lStrIdx = aSubkey5 ; if ( agNULL == lStrIdx ) break ; strcat ( aFullKey , " " ) ; strcat ( aFullKey , lStrIdx ) ; } strcat ( aFullKey , " " ) ; strcat ( aFullKey , aValueName ) ; * apLenFullKey = strlen ( aFullKey ) ; return tiSuccess ; }
ostiMakeParamString()
Purpose:
Utility function to simplify flow in ostiGetTransportParam().
ostiMakeParamString () Purpose : Utility function to simplify flow in ostiGetTransportParam () .
// preliminary sanity checks // start at the beginning of the string // no more key information // append key information // only the value name is left to append // 58 is max len seen; June 11, 2012 // printf( "ostiMakeParamString: x%d out-str:%s\n", // debug print //        *apLenFullKey, aFullKey ); // ship it chief