(root)/
acl-2.3.1/
libacl/
acl_create_entry.c
       1  /*
       2    File: acl_create_entry.c
       3  
       4    Copyright (C) 1999, 2000
       5    Andreas Gruenbacher <andreas.gruenbacher@gmail.com>
       6  
       7    This program is free software; you can redistribute it and/or
       8    modify it under the terms of the GNU Lesser General Public
       9    License as published by the Free Software Foundation; either
      10    version 2.1 of the License, or (at your option) any later version.
      11  
      12    This program is distributed in the hope that it will be useful,
      13    but WITHOUT ANY WARRANTY; without even the implied warranty of
      14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15    Lesser General Public License for more details.
      16  
      17    You should have received a copy of the GNU Lesser General Public
      18    License along with this library; if not, write to the Free Software
      19    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
      20  */
      21  
      22  #include "config.h"
      23  #include "libacl.h"
      24  
      25  
      26  acl_entry_obj *
      27  __acl_create_entry_obj(acl_obj *acl_obj_p)
      28  {
      29  	acl_entry_obj *entry_obj_p, *prev;
      30  
      31  	if (acl_obj_p->aprealloc == acl_obj_p->aprealloc_end) {
      32  		entry_obj_p = new_obj_p(acl_entry);
      33  		if (!entry_obj_p)
      34  			return NULL;
      35  	} else {
      36  		entry_obj_p = --acl_obj_p->aprealloc_end;
      37  		new_obj_p_here(acl_entry, entry_obj_p);
      38  	}
      39  	acl_obj_p->aused++;
      40  
      41  	/* Insert at the end of the entry ring */
      42  	prev = acl_obj_p->aprev;
      43  	entry_obj_p->eprev = prev;
      44  	entry_obj_p->enext = (acl_entry_obj *)acl_obj_p;
      45  	prev->enext = entry_obj_p;
      46  	acl_obj_p->aprev = entry_obj_p;
      47  	
      48  	entry_obj_p->econtainer = acl_obj_p;
      49  	init_acl_entry_obj(*entry_obj_p);
      50  
      51  	return entry_obj_p;
      52  }
      53  
      54  /* 23.4.7 */
      55  int
      56  acl_create_entry(acl_t *acl_p, acl_entry_t *entry_p)
      57  {
      58  	acl_obj *acl_obj_p;
      59  	acl_entry_obj *entry_obj_p;
      60  	if (!acl_p || !entry_p) {
      61  		if (entry_p)
      62  			*entry_p = NULL;
      63  		errno = EINVAL;
      64  		return -1;
      65  	}
      66  	acl_obj_p = ext2int(acl, *acl_p);
      67  	if (!acl_obj_p)
      68  		return -1;
      69  	entry_obj_p = __acl_create_entry_obj(acl_obj_p);
      70  	if (entry_obj_p == NULL)
      71  		return -1;
      72  	*entry_p = int2ext(entry_obj_p);
      73  	return 0;
      74  }
      75