1 static const char CVSID
[] = "$Id: clearcase.c,v 1.4 2002/06/26 23:39:21 slobasso Exp $";
2 /*******************************************************************************
4 * clearcase.c -- Nirvana Editor ClearCase support utilities *
6 * Copyright (C) 2001 Mark Edel *
8 * This is free software; you can redistribute it and/or modify it under the *
9 * terms of the GNU General Public License as published by the Free Software *
10 * Foundation; either version 2 of the License, or (at your option) any later *
13 * This software is distributed in the hope that it will be useful, but WITHOUT *
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
18 * You should have received a copy of the GNU General Public License along with *
19 * software; if not, write to the Free Software Foundation, Inc., 59 Temple *
20 * Place, Suite 330, Boston, MA 02111-1307 USA *
22 * Nirvana Text Editor *
25 * Written by Mark Edel *
27 *******************************************************************************/
30 #include "../config.h"
33 #include "clearcase.h"
38 #include <X11/Intrinsic.h>
44 static int ClearCaseViewTagFound
= 0;
45 static char *ClearCaseViewRoot
= NULL
;
46 static const char *ClearCaseViewTag
= NULL
;
48 const char* GetClearCaseVersionExtendedPath(const char* fullname
)
50 return(strstr(fullname
, "@@/"));
55 ** Return a string showing the ClearCase view tag. If ClearCase is not in
56 ** use, or a view is not set, NULL is returned.
58 ** If user has ClearCase and is in a view, CLEARCASE_ROOT will be set and
59 ** the view tag can be extracted. This check is safe and efficient enough
60 ** that it doesn't impact non-clearcase users, so it is not conditionally
61 ** compiled. (Thanks to Max Vohlken)
63 const char *GetClearCaseViewTag(void)
65 if (!ClearCaseViewTagFound
) {
66 /* Extract the view name from the CLEARCASE_ROOT environment variable */
67 const char *envPtr
= getenv("CLEARCASE_ROOT");
70 ClearCaseViewRoot
= XtMalloc(strlen(envPtr
) + 1);
71 strcpy(ClearCaseViewRoot
, envPtr
);
73 tagPtr
= strrchr(ClearCaseViewRoot
, '/');
75 ClearCaseViewTag
= ++tagPtr
;
79 /* If we don't find it first time, we will never find it, so may just as
80 * well say that we have found it.
82 ClearCaseViewTagFound
= 1;
84 return(ClearCaseViewTag
);