1 static const char CVSID
[] = "$Id: clearcase.c,v 1.1 2001/11/18 19:02:58 arnef 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 <X11/Intrinsic.h>
32 #include "clearcase.h"
35 static int ClearCaseViewTagFound
= 0;
36 static char *ClearCaseViewRoot
= NULL
;
37 static const char *ClearCaseViewTag
= NULL
;
39 const char* GetClearCaseVersionExtendedPath(const char* fullname
)
41 return(strstr(fullname
, "@@/"));
46 ** Return a string showing the ClearCase view tag. If ClearCase is not in
47 ** use, or a view is not set, NULL is returned.
49 ** If user has ClearCase and is in a view, CLEARCASE_ROOT will be set and
50 ** the view tag can be extracted. This check is safe and efficient enough
51 ** that it doesn't impact non-clearcase users, so it is not conditionally
52 ** compiled. (Thanks to Max Vohlken)
54 const char *GetClearCaseViewTag(void)
56 if (!ClearCaseViewTagFound
) {
57 /* Extract the view name from the CLEARCASE_ROOT environment variable */
58 const char *envPtr
= getenv("CLEARCASE_ROOT");
61 ClearCaseViewRoot
= XtMalloc(strlen(envPtr
) + 1);
62 strcpy(ClearCaseViewRoot
, envPtr
);
64 tagPtr
= strrchr(ClearCaseViewRoot
, '/');
66 ClearCaseViewTag
= ++tagPtr
;
70 /* If we don't find it first time, we will never find it, so may just as
71 * well say that we have found it.
73 ClearCaseViewTagFound
= 1;
75 return(ClearCaseViewTag
);