KCMS Application Developer's Guide

KcsSaveProfile()

KcsStatusId
 KcsSaveProfile (KcsProfileId profile, KcsProfileDesc *desc)

Purpose

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:

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.

Arguments

Table 4-21 KcsSaveProfile() Arguments

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.)

Returns

Table 4-22 KcsSaveProfile() Return Strings

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

Example


Example 4-10 KcsSaveProfile()

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);


Note -

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;