nucm-logo

NUCM-2.0 Documentation
Interface: Query: nc_lastversion


[Collection | Query | Attribute]

[nc_list | nc_gettype | nc_version | nc_lastversion | nc_existsversion | nc_isinitiated]

Signature

int  nc_lastversion(const char*  path,
                    const char*  p_cwd,
                    char*  version)

Functionality

Sets the value of the parameter version to the version number of the last created version of the artifact determined by the interpretation of the parameters path and p_cwd. It is assumed that the parameter version holds enough space to place the version number in, i.e., is at least MAX_VERSION_LENGTH in size. The resulting value is NULL-terminated.

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
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", "2", "3", "4", and "5" have been opened in a workspace. The workspace looks as follows:
   /home/bigtime/andre/workspace/my_project/1
					    2
					    3
					    4
					    5
To update the workspace with the last version of each of the artifacts "1", "2", "3", "4", and "5", the following code fragment can be used:
   #include "nc.h"
   
   t_memberlist*  memberlist;
   t_memberlist*  member;
   char  lastversion[MAX_VERSION_LENGTH + 1];
   char  version[MAX_VERSION_LENGTH + 1];
   char  newartifact[MAXPATHLEN + 1];

   nc_list("my_project",
	   "/home/bigtime/andre/workspace",
	   &memberlist);
   member = memberlist;
   while (member != NULL) {
      nc_lastversion(member->name,
		     "/home/bigtime/andre/workspace/my_project",
		     lastversion);
      nc_version(member->name,
		 "/home/bigtime/andre/workspace/my_project",
		 version);
      if (strcmp(lastversion, version) != 0) {
	 nc_close(member->name,
		  "/home/bigtime/andre/workspace/my_project",
		  0);
         sprintf(newartifact, "%s%c%s", member->name, VERSION_SEPARATOR,
		 lastversion);
	 nc_open(newartifact,
		 "/home/bigtime/andre/workspace/my_project",
		 "/home/bigtime/andre/workspace/my_project",
		 "");
      }
      member = member->next;
   }
The workspace looks as follows now (the same as above):
   /home/bigtime/andre/workspace/my_project/1
					    2
					    3
					    4
					    5
The contents of the artifacts "1", "2", "3", "4", and "5" however is different from the previous workspace if the version in the workspace was not identical to the last version of the artifact.

[Top | Quick Index] [Concepts | Interface]

SERL <serl.cs.colorado.edu>