More warning fixes (SF #732742: compiling errors).
[nedit.git] / util / clearcase.c
blob4b5fecacc7396c9f1c057a9a0c47461d2064d644
1 static const char CVSID[] = "$Id: clearcase.c,v 1.4 2002/06/26 23:39:21 slobasso Exp $";
2 /*******************************************************************************
3 * *
4 * clearcase.c -- Nirvana Editor ClearCase support utilities *
5 * *
6 * Copyright (C) 2001 Mark Edel *
7 * *
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. *
12 * *
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 *
16 * for more details. *
17 * *
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 *
21 * *
22 * Nirvana Text Editor *
23 * March, 2001 *
24 * *
25 * Written by Mark Edel *
26 * *
27 *******************************************************************************/
29 #ifdef HAVE_CONFIG_H
30 #include "../config.h"
31 #endif
33 #include "clearcase.h"
35 #include <string.h>
36 #include <stdlib.h>
38 #include <X11/Intrinsic.h>
40 #ifdef HAVE_DEBUG_H
41 #include "../debug.h"
42 #endif
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");
68 if (envPtr != NULL) {
69 const char *tagPtr;
70 ClearCaseViewRoot = XtMalloc(strlen(envPtr) + 1);
71 strcpy(ClearCaseViewRoot, envPtr);
73 tagPtr = strrchr(ClearCaseViewRoot, '/');
74 if (tagPtr != NULL) {
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);