File: sf-get3.cc

package info (click to toggle)
cssc 1.2.0-2
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 3,564 kB
  • ctags: 1,387
  • sloc: cpp: 13,240; sh: 4,771; ansic: 2,992; perl: 342; makefile: 338; awk: 11
file content (167 lines) | stat: -rw-r--r-- 4,279 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
 * sf-get3.cc: Part of GNU CSSC.
 * 
 * 
 *    Copyright (C) 1997,1999,2002,2007 Free Software Foundation, Inc. 
 * 
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * CSSC was originally Based on MySC, by Ross Ridge, which was 
 * placed in the Public Domain.
 *
 *
 * Members of the class sccs_file used by get and delta.
 *
 */

#include "cssc.h"
#include "sccsfile.h"
#include "seqstate.h"
#include "delta-iterator.h"

#ifdef CONFIG_SCCS_IDS
static const char rcs_id[] = "CSSC $Id: sf-get3.cc,v 1.21 2007/12/17 21:59:51 jay Exp $";
#endif

/* Prepare a seqstate for use by marking which sequence numbers are to
 * be included and which are to be excluded.
 */

bool
sccs_file::prepare_seqstate_2(seq_state &state, sid_list include,
                            sid_list exclude, sccs_date cutoff_date)
{
  
  ASSERT(0 != delta_table);
  const_delta_iterator iter(delta_table);

  while (iter.next())
    {
      sid const &id = iter->id;

      if (include.member(id))   // explicitly included on command line
        {
          state.set_explicitly_included(iter->seq,
					(seq_no) seq_state::BY_COMMAND_LINE );
        }
      else if (exclude.member(id)) // explicitly included on command line
        {
          state.set_explicitly_excluded(iter->seq,
					(seq_no) seq_state::BY_COMMAND_LINE );
        }
      else if (cutoff_date.valid() && iter->date > cutoff_date)
        {
          // Delta not explicitly included/excluded by the user, but
          // if it is newer than the cutoff date, we don't want it.
          // This is the feature that allows us to retrieve a delta
          // that was current at some time in the past.
          state.set_excluded(iter->seq, (seq_no) seq_state::BY_COMMAND_LINE);
        }
      
      ASSERT(0 != delta_table);
    }
  ASSERT(0 != delta_table);
  
  return true;
}


bool sccs_file::prepare_seqstate(seq_state &state, seq_no seq,
                                 sid_list include,
                                 sid_list exclude, sccs_date cutoff_date)
{
    if (!prepare_seqstate_1(state, seq))
        return false;
    
    if (!prepare_seqstate_2(state, include, exclude, cutoff_date))
        return false;
    
    return true;
}




bool
sccs_file::authorised() const {
  int i;
  int len;
  
  const char *user = get_user_name();
  
  len = users.length();
  if (len != 0) {
    int found = 0;
    
    for(i = 0; i < len; i++)
      {
        const char *s = users[i].c_str();
        char c = s[0];
      
        // Regular SCCS does not underatand the use of "!username" 
        // to specifically exclude users.  Hence for compatibility 
        // nor must we.  Hence this next if statement is commented out.
#if 0   
      if (c == '!')
        {
          s++;
          if (isdigit(c))
            {
              if (user_is_group_member(atoi(s)))
                {
                  found = 0;
                  break;
                }
            }
          else if (strcmp(s, user) == 0)
            {
              found = 0;
              break;
            }
          else 
            {
              continue;
            }
        }
#endif

      if (isdigit(c))
        {
          if (user_is_group_member(atoi(s)))
            {
              found = 1;
              break;
            }
        } 
      else if (strcmp(s, user) == 0) 
        {
          found = 1;
          break;
        }
      }
    
    if (!found) 
      {
        errormsg("%s: You are not authorized to make deltas.",
                 name.c_str());
        return false;
      }
  }
  return true;
}


/* Local variables: */
/* mode: c++ */
/* End: */