nucm-logo

NUCM-2.0 Documentation
Interface: Attribute: nc_testandsetattribute


[Query | Attribute | Removal]

[nc_testandsetattribute | nc_getattributevalue | nc_removeattribute]

Signature

int  nc_testandsetattribute(const char*  path,
		            const char*  p_cwd,
		            const char*  attrname,
			    const char*  value)

Functionality

If and only if the attribute determined by the parameter attrname does not exist for the NUCM artifact determined by the interpretation of the parameters path and p_cwd, creates this attribute in a NUCM logical repository and sets its value to the value of the parameter value.

Return Values

0: everything went ok
-1: an error occurred

NdbErrno Codes

NdbOk :everything went ok
NdbUnknown :the path does not represent a NUCM artifact
NdbNotOpen :the NUCM artifact has not been opened in the workspace
NdbExist :the attribute exists already and can not be overwritten
NdbConnect :the server is down or not reachable
NdbComm :a communication error occurred
NdbProtocol:a failure occurred in the NUCM protocol
NdbNotAvail:service is not available

Example

Assuming a repository is filled with projects, and in particular contains a project "my_project" that has members "1", "2", "3", "4", and "5". Furthermore, "my_project" and its members "1" and "2" have been opened and initiated in a workspace. The workspace looks as follows:
   /home/bigtime/andre/workspace/my_project/1
					    2
To store a new version of "2" and to record some context of the changes made, the following code fragment can be used:
   #include "nc.h"

   char  newversion[MAX_VERSION_LENGTH + 1];

   nc_commitchange("2",
		   "/home/bigtime/andre/workspace/my_project",
		   &newversion);
   nc_testandsetattribute("my_project/2",
			  "/home/bigtime/andre/workspace",
			  "author",
			  "Andre van der Hoek");
   nc_testandsetattribute("my_project/2",
			  "/home/bigtime/andre/workspace",
			  "comments",
			  "Created a new version to demonstrate NUCM");
   nc_testandsetattribute("my_project/2",
			  "/home/bigtime/andre/workspace",
			  "date",
			  "05/27/1997");

[Top | Quick Index] [Concepts | Interface]

SERL <serl.cs.colorado.edu>