File: oldgaa_alloc.c

package info (click to toggle)
globus-gsi-callback 6.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,756 kB
  • sloc: sh: 11,067; ansic: 5,658; makefile: 93
file content (309 lines) | stat: -rw-r--r-- 8,220 bytes parent folder | download | duplicates (9)
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
/*
 * Copyright 1999-2006 University of Chicago
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**********************************************************************
 oldgaa_alloc.c:

Description:
	This file used internally by the oldgaa routines
**********************************************************************/

#include "globus_oldgaa.h"
#include "oldgaa_gl_internal_err.h"

/*****************************************************************************/

oldgaa_error_code  
oldgaa_allocate_buffer (oldgaa_buffer_ptr*  buffer_addr   /* IN  */)
{
  oldgaa_buffer_ptr  buffer;

  buffer = (oldgaa_buffer_ptr) malloc(sizeof(oldgaa_buffer));
  if (!buffer) out_of_memory();
    
    /* Initialize and fill in default values */

       buffer->length  = 0; 
       buffer->value   = NULL;    
      *buffer_addr     = buffer;
    
       return OLDGAA_SUCCESS;
}

/*****************************************************************************/

oldgaa_error_code  
oldgaa_allocate_data(oldgaa_data_ptr* buffer_addr /* IN  */)
{
  oldgaa_data_ptr  buffer;

  buffer = (oldgaa_data_ptr) malloc(sizeof(oldgaa_data));
  if (!buffer) out_of_memory();
    
    /* Initialize and fill in default values */

       buffer->str         = NULL; 
       buffer->error_str   = NULL;
       buffer->error_code  = 0;

      *buffer_addr = buffer;
    
       return OLDGAA_SUCCESS;
}
/*****************************************************************************/

oldgaa_error_code  
oldgaa_allocate_options (oldgaa_options_ptr*  buffer_addr   /* IN  */)
{
  oldgaa_options_ptr  buffer;

  buffer = (oldgaa_options_ptr) malloc(sizeof(oldgaa_options));
  if (!buffer) out_of_memory();
    
    /* Initialize and fill in default values */

       buffer->length  = 0; 
       buffer->value   = NULL;    
      *buffer_addr     = buffer;
    
       return OLDGAA_SUCCESS;
}

/*****************************************************************************/

oldgaa_error_code
oldgaa_allocate_principals (oldgaa_principals_ptr* buffer_addr)
{
 oldgaa_principals_ptr list = NULL;

  list = (oldgaa_principals_ptr) malloc(sizeof(oldgaa_principals));
  if (!list) out_of_memory();
    

     /* Initialize and fill in default values */

              
     list->type      = NULL;            
     list->authority = NULL;               
     list->value     = NULL;
     list->rights    = NULL;
     list->next      = NULL;             
    *buffer_addr     = list;

     return OLDGAA_SUCCESS;
}

/*****************************************************************************/

oldgaa_error_code
oldgaa_allocate_conditions (oldgaa_conditions_ptr* buffer_addr)
{
 oldgaa_conditions_ptr list = NULL;

  list = (oldgaa_conditions_ptr) malloc(sizeof(oldgaa_conditions));
  if (!list) out_of_memory();
    
     /* Initialize and fill in default values */

     list->type      = NULL;   
     list->authority = NULL;  
     list->value     = NULL;
     list->status    = 0;
     list->next      = NULL;         
     list->reference_count = 0;
    *buffer_addr     = list;

     return OLDGAA_SUCCESS;
}


/*****************************************************************************/

oldgaa_error_code
oldgaa_allocate_rights (oldgaa_rights_ptr* buffer_addr   /* IN  */)
{
 oldgaa_rights_ptr list = NULL;

  list = (oldgaa_rights_ptr) malloc(sizeof(oldgaa_rights));
  if (!list) out_of_memory();
    
#ifdef DEBUG
fprintf(stderr,"oldgaa_allocate_rights:%p\n",list);
#endif
     /* Initialize and fill in default values */

     list->type          = NULL;          
     list->authority     = NULL;          
     list->value         = NULL;
     list->cond_bindings = NULL;
     list->next          = NULL;           
     list->reference_count = 0;
    *buffer_addr         = list;

     return OLDGAA_SUCCESS;
}


/*****************************************************************************/

oldgaa_error_code
oldgaa_allocate_cond_bindings (oldgaa_cond_bindings_ptr* buffer_addr   /* IN  */)
{
 oldgaa_cond_bindings_ptr list = NULL;

  list = (oldgaa_cond_bindings_ptr) malloc(sizeof(oldgaa_cond_bindings));
  if (!list) out_of_memory();
    
#ifdef DEBUG
fprintf(stderr,"oldgaa_allocate_cond_bindings:%p\n",list);
#endif
     /* Initialize and fill in default values */
  
     list->condition = NULL;
     list->next      = NULL;           
	 list->reference_count = 0;
    *buffer_addr     = list;

     return OLDGAA_SUCCESS;
}


/*****************************************************************************/

oldgaa_error_code
oldgaa_allocate_sec_attrb (oldgaa_sec_attrb_ptr* buffer_addr   /* IN  */)
{
 oldgaa_sec_attrb_ptr list = NULL;

  list = (oldgaa_sec_attrb_ptr) malloc(sizeof(oldgaa_sec_attrb));
  if (!list) out_of_memory();
    
     /* Initialize and fill in default values */
        
     list->type      = NULL;            
     list->authority = NULL;        
     list->value     = NULL;
     list->next      = NULL;          
    *buffer_addr     = list;

     return OLDGAA_SUCCESS;
}


/*****************************************************************************/

oldgaa_error_code  
oldgaa_allocate_sec_context (oldgaa_sec_context_ptr*  buffer_addr)

{   
    oldgaa_sec_context_ptr   buffer; 
    oldgaa_identity_cred_ptr ident;

    buffer = (oldgaa_sec_context_ptr) malloc(sizeof(oldgaa_sec_context));
    if (!buffer) out_of_memory();
      
    /* Initialize and fill in default values */
   
       oldgaa_allocate_identity_cred(&ident);    
      
       buffer->identity_cred         = ident;

       buffer->authr_cred            = NULL;
       buffer->group_membership      = NULL;
       buffer->group_non_membership  = NULL;
       buffer->attributes            = NULL;
       buffer->unevl_cred            = NULL;
       buffer->connection_state      = NULL;

       buffer->condition_evaluation  = NULL;
       buffer->pull_cred             = NULL;
       buffer->cred_evaluate         = NULL;
           
      *buffer_addr = buffer;

       return OLDGAA_SUCCESS;
}

                     
/*****************************************************************************/

oldgaa_error_code
oldgaa_allocate_identity_cred(oldgaa_identity_cred_ptr*  buffer_addr  /* IN&OUT */)

{  
   oldgaa_buffer_ptr         ptr        = NULL;
   oldgaa_principals_ptr     principals = NULL;
   oldgaa_conditions_ptr     conditions = NULL;
   oldgaa_identity_cred_ptr  buffer     = NULL;

   buffer = (oldgaa_identity_cred_ptr) malloc(sizeof(oldgaa_identity_cred));
   if (!buffer) out_of_memory();
      

    /* Initialize and fill in default values */

       oldgaa_allocate_principals(&principals);
          
       buffer->principal  = principals;

       oldgaa_allocate_conditions(&conditions);
	   conditions->reference_count++;
          
       buffer->conditions  = conditions;
    
       oldgaa_allocate_buffer(&ptr);
          
       buffer->mech_spec_cred = ptr;
       buffer->next = NULL;

  
  *buffer_addr = buffer;

   return OLDGAA_SUCCESS;
   
}


/*****************************************************************************/

oldgaa_error_code
oldgaa_allocate_answer(oldgaa_answer_ptr *ptr)
{
  oldgaa_time_period_ptr time   = NULL;
  oldgaa_answer_ptr      buffer = NULL;

  /* Initialize and fill in default values */
 
  time  = (oldgaa_time_period_ptr) malloc(sizeof(oldgaa_time_period));
  if (!time) out_of_memory();

  time->start_time = 0;
  time->end_time   = 0;

  buffer = (oldgaa_answer_ptr) malloc(sizeof(oldgaa_answer));
  if (!buffer) out_of_memory();
      
  buffer->valid_time = time;
  buffer->rights     = NULL;

 *ptr = buffer;

  return OLDGAA_SUCCESS;
}

/*****************************************************************************/