KCMS CMM Developer's Guide

Example

The following example shows you how to use the entry points when creating a KcsIO derivative.


Example 4-1 KcsIO Class Entry Points Example

/* External loadable interface */ 
extern "C"
     extern long          KcsDLOpenIOCount;
     KcsStatus            KcsInitIO();
     KcsIO                *KcsCreateIO(KcsStatus *aStatus, 
                              const KcsProfileDesc *aDesc);
     KcsStatus            KcsCleanupIO(); 
//Loadable stuff 
//external DL open count to support runtime derivation 
extern long KcsDLOpenIOCount = 0; 

/* Runtime derivable routine */ 
KcsIO *
KcsCreateIO(KcsStatus *aStat, const KcsProfileDesc *Desc) 
{
     //Create the new derivative
     return(new KcsSolarisFile(aStat,
        aDesc->desc.solarisFile.fileName, aDesc->desc.solarisFile.hostName,
        aDesc->desc.solarisFile.oflag, aDesc->desc.solarisFile.mode);
} 

KcsStatus 
KcsInitIO(long libMajor, long libMinor, long *myMajor, long *myMinor)
{
     // Set up the return values
     *myMajor = KCS_MAJOR_VERSION;
     *myMinor = KCS_MINOR_VERSION;

     //Check the major version
     if (libMajor != KCS_MAJOR_VERSION)
       return (KCS_CMM_MAJOR_VERSION_MISMATCH);

     //Currently, if minor version of library is less than the KCMS
     // minor version, return an error.
     if (libMinor != KCS_MINOR_VERSION)
        return (KCS_CMM_MINOR_VERSION_MISMATCH);

     //Library guarantees if your minor version number is greater than
     //KCMS minor version number, it will handle it. No more init.
     return(KCS_SUCCESS); 
}

KcsStatus KcsCleanupIO() 
{
     /* Clean up is performed in the destructor */
     return (KCS_SUCCESS);
}