"Fossies" - the Fresh Open Source Software Archive

Member "CSSC-1.4.1/src/sccsname.h" (7 May 2019, 2869 Bytes) of package /linux/privat/CSSC-1.4.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "sccsname.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.4.0_vs_1.4.1.

    1 /*
    2  * sccsname.h: Part of GNU CSSC.
    3  *
    4  *
    5  *  Copyright (C) 1997, 2001, 2007, 2008, 2009, 2010, 2011, 2014, 2019
    6  *  Free Software Foundation, Inc.
    7  *
    8  *  This program is free software: you can redistribute it and/or modify
    9  *  it under the terms of the GNU General Public License as published by
   10  *  the Free Software Foundation, either version 3 of the License, or
   11  *  (at your option) any later version.
   12  *
   13  *  This program is distributed in the hope that it will be useful,
   14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16  *  GNU General Public License for more details.
   17  *
   18  *  You should have received a copy of the GNU General Public License
   19  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
   20  *
   21  * CSSC was originally Based on MySC, by Ross Ridge, which was
   22  * placed in the Public Domain.
   23  *
   24  *
   25  * Defines the class sccs_name.
   26  *
   27  * @(#) CSSC sccsname.h 1.1 93/11/09 17:17:50
   28  *
   29  */
   30 
   31 #ifndef CSSC__SCCSNAME_H__
   32 #define CSSC__SCCSNAME_H__
   33 
   34 #include <string>
   35 using std::string;
   36 
   37 #include "filelock.h"
   38 
   39 string base_part(const string &name);
   40 string canonify_filename(const char* fname);
   41 
   42 class sccs_name
   43 {
   44   string sname;     // name of the s. file.
   45   string gname;
   46 
   47   // We hold separate strings for the part before
   48   // and the part after the character that changes:
   49   //  dir/s.foo.c
   50   //  dir/p.foo.c
   51   //  dir/z.foo.c
   52   //  dir/l.foo.c
   53   // In these cases, name_front is "dir/" and name_rear is ".foo.c".
   54 
   55   string name_front, name_rear;
   56 
   57   file_lock *lock_ptr;
   58   int lock_cnt;
   59 
   60   void create();
   61 
   62   void
   63   destroy()
   64   {
   65     if (lock_cnt > 0)
   66       delete lock_ptr;
   67   }
   68 
   69   sccs_name &operator =(sccs_name const &);
   70   sccs_name(sccs_name const &);
   71 
   72 public:
   73   static int valid_filename(const char *name);
   74   /* The initialisers on the following line have been re-ordered
   75    * to follow the declaration order.
   76    */
   77   sccs_name(): lock_ptr(0), lock_cnt(0)  {}
   78   sccs_name &operator =(const string& n); /* undefined */
   79 
   80   bool valid() const { return sname.length() > 0; }
   81   void make_valid();
   82 
   83   const char * c_str() const { return sname.c_str(); }
   84 
   85   string sub_file(char insertme) const;
   86   string sfile() const { return sname; }
   87   string gfile() const { return gname; }
   88   string lfile() const;
   89 
   90   string pfile() const { return sub_file('p'); }
   91   string qfile() const { return sub_file('q'); }
   92   string xfile() const { return sub_file('x'); }
   93   string zfile() const { return sub_file('z'); }
   94 
   95   int
   96   lock()
   97   {
   98     if (lock_cnt++ == 0)
   99       {
  100     string zf = zfile();
  101     lock_ptr = new file_lock(zf);
  102     return lock_ptr->failed();
  103       }
  104     return 0;
  105   }
  106 
  107   void
  108   unlock()
  109   {
  110     if (--lock_cnt == 0)
  111       {
  112     delete lock_ptr;
  113       }
  114   }
  115 
  116   ~sccs_name()
  117   {
  118     destroy();
  119   }
  120 };
  121 
  122 #endif /* __SCCSNAME_H__ */
  123 
  124 /* Local variables: */
  125 /* mode: c++ */
  126 /* End: */