KcsStatusId KcsSaveProfile (KcsProfileId profile, KcsProfileDesc *desc) |
Use KcsSaveProfile() to save a loaded profile, and any changes to its attributes or profile data, to the mechanism described by desc.
If supported by the mechanism, a profile's state can be saved at an offset. For example, if the mechanism indicates a file, the following two situations are applicable:
Your application creates a file containing only one profile. In this case most typically the offset is 0.
Your application creates a file containing one profile plus some application data (like a TIFF file). Your application must ensure that the profile fits into the file format and does not overwrite data nor is itself overwritten. It can determine the length of the data read from the file by calling KcsGetAttribute() and supplying the icHeader attribute. The value of size in the icHeader structure is the size of the profile. For the format of the icHeader structure, see "icHeader ".
KcsSaveProfile() writes information, but does not free the profile. Even after saving the profile, the application can continue to use it. In fact, the application must call KcsFreeProfile() to free all resources associated with the profile.
Argument |
Description |
---|---|
profile |
The identifier of the loaded profile.Typically, your application obtains this value when it calls KcsLoadProfile() or KcsConnectProfiles(). |
desc |
The location of the profile's static storage mechanism, needed to obtain the data required to generate the profile's resources. It is specified as a union of independent static storage mechanisms. This argument has a field that identifies which storage mechanism to use. If this field is NULL, the profile is saved through the same mechanism from which it was loaded. (See "KcsProfileId " for more information.) |
KCS_SUCCESS |
KCS_IO_WRITE_ERR |
KCS_IO_READ_ERR |
KCS_IO_SEEK_ERR |
KCS_SOLARIS_FILE_NOT_OPENED |
KCS_SOLARIS_FILE_RO |
KCS_SOLARIS_FILE_LOCKED |
KCS_SOLARIS_FILE_NAME_NULL |
KCS_X11_DATA_NULL |
KCS_X11_PROFILE_NOT_LOADED |
KCS_X11_PROFILE_RO |
KcsProfileDesc desc; KcsProfileId profileid; KcsStatusId status; KcsErrDesc errDesc; /*see example kcms_update.c for a full example code */ desc.type = KcsSolarisProfile; desc.desc.solarisFile.fileName = argv[1]; desc.desc.solarisFile.hostName = NULL; desc.desc.solarisFile.mode = 0; desc.desc.solarisFile.oflag = O_RDWR status = KcsSaveProfile(profileid, &desc); if(status != KCS_SUCCESS) { status = KcsGetLastError(&errDesc); fprintf(stderr,"KcsSaveProfile failed error = %s\n", errDesc.desc); } KcsFreeProfile(profileid); |
If you are saving a new profile, use the following assignments instead of the assignments in Example 4-10.
desc.desc.solarisFile.mode = 0666;
desc.desc.solarisFile.oflag = O_RDWR | O_CREAT | O_TRUNC;