1 static const char CVSID
[] = "$Id: clearcase.c,v 1.6 2004/11/09 21:58:45 yooden 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 *
11 * version. In addition, you may distribute versions of this program linked to *
12 * Motif or Open Motif. See README for details. *
14 * This software is distributed in the hope that it will be useful, but WITHOUT *
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
19 * You should have received a copy of the GNU General Public License along with *
20 * software; if not, write to the Free Software Foundation, Inc., 59 Temple *
21 * Place, Suite 330, Boston, MA 02111-1307 USA *
23 * Nirvana Text Editor *
26 * Written by Mark Edel *
28 *******************************************************************************/
31 #include "../config.h"
34 #include "clearcase.h"
39 #include <X11/Intrinsic.h>
45 static int ClearCaseViewTagFound
= 0;
46 static char *ClearCaseViewRoot
= NULL
;
47 static const char *ClearCaseViewTag
= NULL
;
49 const char* GetClearCaseVersionExtendedPath(const char* fullname
)
51 return(strstr(fullname
, "@@/"));
56 ** Return a string showing the ClearCase view tag. If ClearCase is not in
57 ** use, or a view is not set, NULL is returned.
59 ** If user has ClearCase and is in a view, CLEARCASE_ROOT will be set and
60 ** the view tag can be extracted. This check is safe and efficient enough
61 ** that it doesn't impact non-clearcase users, so it is not conditionally
62 ** compiled. (Thanks to Max Vohlken)
64 const char *GetClearCaseViewTag(void)
66 if (!ClearCaseViewTagFound
) {
67 /* Extract the view name from the CLEARCASE_ROOT environment variable */
68 const char *envPtr
= getenv("CLEARCASE_ROOT");
71 ClearCaseViewRoot
= XtMalloc(strlen(envPtr
) + 1);
72 strcpy(ClearCaseViewRoot
, envPtr
);
74 tagPtr
= strrchr(ClearCaseViewRoot
, '/');
76 ClearCaseViewTag
= ++tagPtr
;
80 /* If we don't find it first time, we will never find it, so may just as
81 * well say that we have found it.
83 ClearCaseViewTagFound
= 1;
85 return(ClearCaseViewTag
);