nucm-logo

NUCM-2.0 Documentation
Interface: Access: nc_open


[Miscellaneous | Access | Versioning]

[nc_open | nc_close]

Signature

int  nc_open(const char*  path,
             const char*  p_cwd,
	     const char*  prefix_target,
             const char*  t_cwd)

Functionality

Gains access to the artifact determined by the parameters path and p_cwd and places its contents in the workspace determined by the parameters prefix_target and t_cwd. The contents of the artifact is always retrieved from a NUCM logical repository, even if the parameters path and p_cwd point to an artifact already existing in another workspace.

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 determined by path and p_cwd has not been opened in the workspace
NdbOpen :the artifact is already open in the workspace
NdbExist : a different artifact with the same name already exists in the workspace
NdbUnequal: the path and target represent two different artifacts that have the same name
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 our repository is filled with projects, and in particular contains a project "my_project" that has the members "1", "2", "3", "4", and "5". Assuming furthermore a workspace exist with no contents at this point:
   /home/bigtime/andre/workspace
This project and its members can be opened in the workspace as follows:
   #include "nc.h"

   t_memberlist*  memberlist;
   t_memberlist*  member;

   nc_open("//serl.cs.colorado.edu:1234/nucm_root/my_project",
	   "",
	   "/home/bigtime/andre/workspace",
	   "");
   nc_list("my_project",
	   "/home/bigtime/andre/workspace",
	   &memberlist);
   member = memberlist;
   while (member != NULL) {
      nc_open(member->name,
	      "/home/bigtime/andre/workspace/my_project",
	      "/home/bigtime/andre/workspace/my_project",
	      "");
      member = member->next;
   }
Note that the first call to nc_open uses a path that includes a repository, but that the subsequent calls simply use a path in the workspace to open artifacts. Execution of the above code fragment results in the following workspace contents:
   /home/bigtime/andre/workspace/my_project/1
					    2
					    3
					    4
					    5
An alternative use of nc_open occurs when existing artifacts in a workspace are opened in a different workspace. For example, to make a copy of the above workspace in a different workspace "/home/serl/carzanig/workspace", the following code fragment can be used:
   #include "nc.h"

   t_memberlist*  memberlist;
   t_memberlist*  member;

   nc_open("/home/bigtime/andre/workspace/my_project",
	   "",
	   "/home/serl/carzanig/workspace",
	   "");
   nc_list("my_project",
	   "/home/bigtime/andre/workspace",
	   &memberlist);
   member = memberlist;
   while (member != NULL) {
      nc_open(member->name,
	      "/home/bigtime/andre/workspace/my_project",
	      "/home/serl/carzanig/workspace/my_project",
	      "");
      member = member->next;
   }
The result of execution of this code fragment is two identical workspaces that reside in different places.

[Top | Quick Index] [Concepts | Interface]

SERL <serl.cs.colorado.edu>