src/lib/ppc405lib/ssx_io.c
/// Initialize an SSX I/O FILE structure
///
/// \param file A pointer to an uninitialized FILE
///
/// \param flags Flags for the generic FILE
///
/// This API is designed to be called from "constructors of classes derived
/// from FILE", e.g., the StringStream.  The generic FILE structure is
/// cleared, and the flags are installed and other initialization based on the
/// flags is performed. The subclass constructors then install function
/// pointers for any of the FILE functions that they implement.
///
/// \retval 0 Success
///
/// \retval -FILE_INVALID_OBJECT The \a file pointer is null (0).
///
/// \retval -FILE_INVALID_ARGUMENT The \a flags are not valid.
Initialize an SSX I/O FILE structure
\param file A pointer to an uninitialized FILE

\param flags Flags for the generic FILE

This API is designed to be called from "constructors of classes derived
from FILE", e.g., the StringStream.  The generic FILE structure is
cleared, and the flags are installed and other initialization based on the
flags is performed. The subclass constructors then install function
pointers for any of the FILE functions that they implement.

\retval 0 Success

\retval -FILE_INVALID_OBJECT The \a file pointer is null (0).

\retval -FILE_INVALID_ARGUMENT The \a flags are not valid.
Initialize an SSX I / O FILE structure \ param file A pointer to an uninitialized FILE \ param flags Flags for the generic FILE This API is designed to be called from " constructors of classes derived from FILE " e . g . the StringStream . The generic FILE structure is cleared and the flags are installed and other initialization based on the flags is performed . The subclass constructors then install function pointers for any of the FILE functions that they implement . \ retval 0 Success \ retval - FILE_INVALID_OBJECT The \ a file pointer is null ( 0 ) . \ retval - FILE_INVALID_ARGUMENT The \ a flags are not valid .
int
FILE_create(FILE* file, int flags)
{
    if (SSX_ERROR_CHECK_API) {
        SSX_ERROR_IF(file == 0, FILE_INVALID_OBJECT);
        SSX_ERROR_IF(flags & ~SSX_FILE_VALID_FLAGS, FILE_INVALID_ARGUMENT);
        SSX_ERROR_IF(__builtin_popcount(flags & SSX_FILE_OP_LOCK_OPTIONS) > 1,
                     FILE_INVALID_ARGUMENT);
    }
    memset((void*)file, 0, sizeof(FILE));
    file->flags = flags;
    ssx_semaphore_create(&(file->fop_sem), 1, 1);
    return 0;
}
int FILE_create ( FILE * file , int flags ) { if ( SSX_ERROR_CHECK_API ) { SSX_ERROR_IF ( file == 0 , FILE_INVALID_OBJECT ) ; SSX_ERROR_IF ( flags & ~ SSX_FILE_VALID_FLAGS , FILE_INVALID_ARGUMENT ) ; SSX_ERROR_IF ( __builtin_popcount ( flags & SSX_FILE_OP_LOCK_OPTIONS ) > 1 , FILE_INVALID_ARGUMENT ) ; } memset ( ( void * ) file , 0 , sizeof ( FILE ) ) ; file -> flags = flags ; ssx_semaphore_create ( & ( file -> fop_sem ) , 1 , 1 ) ; return 0 ; }
Initialize an SSX I/O FILE structure
\param file A pointer to an uninitialized FILE
Initialize an SSX I / O FILE structure \ param file A pointer to an uninitialized FILE