1 /******************************************************************************* 2 * * 3 * clearcase.c -- Nirvana Editor ClearCase support utilities * 4 * * 5 * Copyright (C) 2001 Mark Edel * 6 * * 7 * This is free software; you can redistribute it and/or modify it under the * 8 * terms of the GNU General Public License as published by the Free Software * 9 * Foundation; either version 2 of the License, or (at your option) any later *10 * version. In addition, you may distribute versions of this program linked to *11 * Motif or Open Motif. See README for details. *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 General Public License for *16 * 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 *******************************************************************************/28 29 #ifdefHAVE_CONFIG_H30 #include"../config.h"31 #endif32 33 #include"clearcase.h"34 #include"nedit_malloc.h"35 36 #include<string.h>37 #include<stdlib.h>38 39 #include<X11/Intrinsic.h>40 41 #ifdefHAVE_DEBUG_H42 #include"../debug.h"43 #endif44 45 staticint ClearCaseViewTagFound = 0;
46 staticchar *ClearCaseViewRoot = NULL;
47 staticconstchar *ClearCaseViewTag = NULL;
48 49 constchar* GetClearCaseVersionExtendedPath(constchar* fullname)
50 {
51 return(strstr(fullname, "@@/"));
52 }
53 54 55 /*56 ** Return a string showing the ClearCase view tag. If ClearCase is not in57 ** use, or a view is not set, NULL is returned.58 **59 ** If user has ClearCase and is in a view, CLEARCASE_ROOT will be set and60 ** the view tag can be extracted. This check is safe and efficient enough61 ** that it doesn't impact non-clearcase users, so it is not conditionally62 ** compiled. (Thanks to Max Vohlken)63 */64 constchar *GetClearCaseViewTag(void)
65 {
66 if (!ClearCaseViewTagFound) {
67 /* Extract the view name from the CLEARCASE_ROOT environment variable */68 constchar *envPtr = getenv("CLEARCASE_ROOT");
69 if (envPtr != NULL) {
70 constchar *tagPtr;
71 ClearCaseViewRoot = NEditStrdup(envPtr);
72 73 tagPtr = strrchr(ClearCaseViewRoot, '/');
74 if (tagPtr != NULL) {
75 ClearCaseViewTag = ++tagPtr;
76 }
77 }
78 }
79 /* If we don't find it first time, we will never find it, so may just as80 * well say that we have found it.81 */82 ClearCaseViewTagFound = 1;
83 84 return(ClearCaseViewTag);
85 }
86