libisofs  1.5.4
About: libisofs is a library to create an ISO 9660 filesystem, supports extensions like RockRidge or Joliet, makes bootable ISO 9660, and records file attributes which are of interest for data backups.
  Fossies Dox: libisofs-1.5.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

aaip_0_2.h File Reference
#include <unistd.h>
Include dependency graph for aaip_0_2.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define Aaip_h_is_includeD   yes
 

Functions

ssize_t aaip_encode (size_t num_attrs, char **names, size_t *value_lengths, char **values, size_t *result_len, unsigned char **result, int flag)
 
int aaip_encode_acl (char *acl_text, mode_t st_mode, size_t *result_len, unsigned char **result, int flag)
 
int aaip_encode_both_acl (char *a_acl_text, char *d_acl_text, mode_t st_mode, size_t *result_len, unsigned char **result, int flag)
 
int aaip_cleanout_st_mode (char *acl_text, mode_t *st_mode, int flag)
 
int aaip_add_acl_st_mode (char *acl_text, mode_t st_mode, int flag)
 
int aaip_local_attr_support (int flag)
 
int aaip_get_acl_text (char *path, char **text, int flag)
 
int aaip_get_attr_list (char *path, size_t *num_attrs, char ***names, size_t **value_lengths, char ***values, int flag)
 
size_t aaip_count_bytes (unsigned char *data, int flag)
 
size_t aaip_sizeof_aaip_state (void)
 
int aaip_init_aaip_state (struct aaip_state *aaip, int flag)
 
int aaip_submit_data (struct aaip_state *aaip, unsigned char *data, size_t num_data, size_t *ready_bytes, int flag)
 
int aaip_fetch_data (struct aaip_state *aaip, char *result, size_t result_size, size_t *num_result, int flag)
 
int aaip_skip_component (struct aaip_state *aaip, int flag)
 
int aaip_decode_pair (struct aaip_state *aaip, unsigned char *data, size_t num_data, size_t *consumed, char *name, size_t name_size, size_t *name_fill, char *value, size_t value_size, size_t *value_fill, int flag)
 
unsigned int aaip_get_pairs_skipped (struct aaip_state *aaip, int flag)
 
int aaip_decode_attrs (struct aaip_state **handle, size_t memory_limit, size_t num_attr_limit, unsigned char *data, size_t num_data, size_t *consumed, int flag)
 
int aaip_get_decoded_attrs (struct aaip_state **handle, size_t *num_attrs, char ***names, size_t **value_lengths, char ***values, int flag)
 
int aaip_decode_acl (unsigned char *data, size_t num_data, size_t *consumed, char *acl_text, size_t acl_text_size, size_t *acl_text_fill, int flag)
 
int aaip_set_acl_text (char *path, char *text, int flag)
 
int aaip_set_attr_list (char *path, size_t num_attrs, char **names, size_t *value_lengths, char **values, int *errnos, int flag)
 

Macro Definition Documentation

◆ Aaip_h_is_includeD

#define Aaip_h_is_includeD   yes

Definition at line 22 of file aaip_0_2.h.

Function Documentation

◆ aaip_add_acl_st_mode()

int aaip_add_acl_st_mode ( char *  acl_text,
mode_t  st_mode,
int  flag 
)

Definition at line 865 of file aaip_0_2.c.

866 {
867  char *wpt;
868  int tag_types= 0;
869 
870  tag_types = aaip_cleanout_st_mode(acl_text, &st_mode, 1);
871  if(!(tag_types & (4 | 32))) {
872  wpt= acl_text + strlen(acl_text);
873  sprintf(wpt, "user::%c%c%c\n",
874  st_mode & S_IRUSR ? 'r' : '-',
875  st_mode & S_IWUSR ? 'w' : '-',
876  st_mode & S_IXUSR ? 'x' : '-');
877  }
878  if(!(tag_types & (2 | 16 | 1024))) {
879  wpt= acl_text + strlen(acl_text);
880  sprintf(wpt, "group::%c%c%c\n",
881  st_mode & S_IRGRP ? 'r' : '-',
882  st_mode & S_IWGRP ? 'w' : '-',
883  st_mode & S_IXGRP ? 'x' : '-');
884  }
885  if(!(tag_types & (1 | 8))) {
886  wpt= acl_text + strlen(acl_text);
887  sprintf(wpt, "other::%c%c%c\n",
888  st_mode & S_IROTH ? 'r' : '-',
889  st_mode & S_IWOTH ? 'w' : '-',
890  st_mode & S_IXOTH ? 'x' : '-');
891  }
892  if((tag_types & (128 | 256)) && !(tag_types & 512)) {
893  wpt= acl_text + strlen(acl_text);
894  sprintf(wpt, "mask::%c%c%c\n",
895  st_mode & S_IRGRP ? 'r' : '-',
896  st_mode & S_IWGRP ? 'w' : '-',
897  st_mode & S_IXGRP ? 'x' : '-');
898  }
899  return(1);
900 }
int aaip_cleanout_st_mode(char *acl_text, mode_t *in_st_mode, int flag)
Definition: aaip_0_2.c:720

References aaip_cleanout_st_mode().

Referenced by iso_attr_get_acl_text().

◆ aaip_cleanout_st_mode()

int aaip_cleanout_st_mode ( char *  acl_text,
mode_t *  st_mode,
int  flag 
)

Definition at line 720 of file aaip_0_2.c.

721 {
722  char *rpt, *wpt, *npt, *cpt;
723  mode_t m, list_mode, st_mode;
724  int tag_types= 0, has_mask= 0, do_cleanout = 0;
725 
726  list_mode= st_mode= *in_st_mode;
727  do_cleanout = !(flag & 15);
728 
729  has_mask= strncmp(acl_text, "mask:", 5) == 0 ||
730  strstr(acl_text, "\nmask:") != NULL;
731  if(has_mask && (flag & 2))
732  return(64 | 512);
733 
734  for(npt= wpt= rpt= acl_text; *npt != 0; rpt= npt + 1) {
735  npt= strchr(rpt, '\n');
736  if(npt == NULL)
737  npt= rpt + strlen(rpt);
738  if(strncmp(rpt, "user:", 5) == 0) {
739  if(rpt[5] == ':' && npt - rpt == 9) {
740  cpt= rpt + 6;
741  m= 0;
742  if(cpt[0] == 'r')
743  m|= S_IRUSR;
744  if(cpt[1] == 'w')
745  m|= S_IWUSR;
746  if(cpt[2] == 'x')
747  m|= S_IXUSR;
748  list_mode= (list_mode & ~S_IRWXU) | m;
749  if((st_mode & S_IRWXU) == (m & S_IRWXU)) {
750  tag_types|= 32;
751  continue;
752  }
753  if(flag & 8) {
754  cpt[0]= st_mode & S_IRUSR ? 'r' : '-';
755  cpt[1]= st_mode & S_IWUSR ? 'w' : '-';
756  cpt[2]= st_mode & S_IXUSR ? 'x' : '-';
757  }
758  tag_types|= 4;
759  } else {
760  tag_types|= 64 | 128;
761  }
762  } else if(strncmp(rpt, "group:", 6) == 0) {
763  if(rpt[6] == ':' && npt - rpt == 10 && ((flag & 16) || !has_mask)) {
764  /* oddly: mask overrides group in st_mode */
765  cpt= rpt + 7;
766  m= 0;
767  if(cpt[0] == 'r')
768  m|= S_IRGRP;
769  if(cpt[1] == 'w')
770  m|= S_IWGRP;
771  if(cpt[2] == 'x')
772  m|= S_IXGRP;
773  list_mode= (list_mode & ~S_IRWXG) | m;
774  if((st_mode & S_IRWXG) == (m & S_IRWXG)) {
775  tag_types|= 16;
776  continue;
777  }
778  if(flag & 8) {
779  cpt[0]= st_mode & S_IRGRP ? 'r' : '-';
780  cpt[1]= st_mode & S_IWGRP ? 'w' : '-';
781  cpt[2]= st_mode & S_IXGRP ? 'x' : '-';
782  }
783  tag_types|= 2;
784  } else {
785  if(rpt[6] == ':' && npt - rpt == 10)
786  tag_types|= 1024;
787  else
788  tag_types|= 64 | 256;
789  }
790  } else if(strncmp(rpt, "other::", 7) == 0 && npt - rpt == 10) {
791  cpt= rpt + 7;
792 others_st_mode:;
793  m= 0;
794  if(cpt[0] == 'r')
795  m|= S_IROTH;
796  if(cpt[1] == 'w')
797  m|= S_IWOTH;
798  if(cpt[2] == 'x')
799  m|= S_IXOTH;
800  list_mode= (list_mode & ~S_IRWXO) | m;
801  if((st_mode & S_IRWXO) == (m & S_IRWXO)) {
802  tag_types|= 8;
803  continue;
804  }
805  if(flag & 8) {
806  cpt[0]= st_mode & S_IROTH ? 'r' : '-';
807  cpt[1]= st_mode & S_IWOTH ? 'w' : '-';
808  cpt[2]= st_mode & S_IXOTH ? 'x' : '-';
809  }
810  tag_types|= 1;
811  } else if(strncmp(rpt, "other:", 6) == 0 && npt - rpt == 9) {
812  cpt= rpt + 7;
813  goto others_st_mode;
814  } else if(strncmp(rpt, "mask::", 6) == 0 && npt - rpt == 9) {
815  cpt= rpt + 6;
816 mask_st_mode:;
817  tag_types|= 64 | 512;
818  if(!(flag & 16)) {
819  /* oddly: mask overrides group in st_mode */
820  m= 0;
821  if(cpt[0] == 'r')
822  m|= S_IRGRP;
823  if(cpt[1] == 'w')
824  m|= S_IWGRP;
825  if(cpt[2] == 'x')
826  m|= S_IXGRP;
827  list_mode= (list_mode & ~S_IRWXG) | m;
828  if(flag & 8) {
829  cpt[0]= st_mode & S_IRGRP ? 'r' : '-';
830  cpt[1]= st_mode & S_IWGRP ? 'w' : '-';
831  cpt[2]= st_mode & S_IXGRP ? 'x' : '-';
832  }
833  }
834  } else if(strncmp(rpt, "mask:", 5) == 0 && npt - rpt == 8) {
835  cpt= rpt + 5;
836  goto mask_st_mode;
837  } else if(*rpt != 0) {
838  tag_types|= 64;
839  }
840  if (flag & 2)
841  goto ex;
842  if(wpt == rpt) {
843  wpt= npt + 1;
844  continue;
845  }
846  if(do_cleanout)
847  memmove(wpt, rpt, 1 + npt - rpt);
848  wpt+= 1 + npt - rpt;
849  }
850  if(do_cleanout) {
851  if(wpt == acl_text)
852  *wpt= 0;
853  else if(*(wpt - 1) != 0)
854  *wpt= 0;
855  }
856 ex:;
857  if(flag & 4)
858  *in_st_mode= list_mode;
859  return(tag_types);
860 }

Referenced by aaip_add_acl_st_mode(), aaip_get_acl_text(), default_create_node(), iso_local_get_perms_wo_acl(), iso_node_get_perms_wo_acl(), iso_node_set_acl_text(), and src_aa_to_node().

◆ aaip_count_bytes()

size_t aaip_count_bytes ( unsigned char *  data,
int  flag 
)

Definition at line 966 of file aaip_0_2.c.

967 {
968  int done = 0;
969  unsigned char *aapt;
970 
971  for(aapt= data; !done; aapt += aapt[2])
972  done = !(aapt[4] & 1);
973  return((size_t) (aapt - data));
974 }

Referenced by aaip_xinfo_cloner(), add_aa_string(), ifs_get_aa_string(), iso_aa_get_attrs(), iso_node_cmp_flag(), and susp_calc_nm_sl_al().

◆ aaip_decode_acl()

int aaip_decode_acl ( unsigned char *  data,
size_t  num_data,
size_t *  consumed,
char *  acl_text,
size_t  acl_text_size,
size_t *  acl_text_fill,
int  flag 
)

Definition at line 2103 of file aaip_0_2.c.

2106 {
2107  unsigned char *rpt;
2108  char perm_text[4], *wpt, *name= NULL;
2109  int type, qualifier= 0, perm, ret, cnt, name_size= 1024;
2110  size_t w_size= 0, name_fill= 0, i;
2111  uid_t uid;
2112  gid_t gid;
2113  struct passwd *pwd;
2114  struct group *grp;
2115 
2116  LIBISO_ALLOC_MEM(name, char, name_size);
2117  cnt= flag & 1;
2118  *consumed= 0;
2119  wpt= acl_text;
2120  w_size= acl_text_size;
2121  *acl_text_fill= 0;
2122  for(rpt= data; (size_t) (rpt - data) < num_data; ) {
2123  perm= *rpt;
2124  strcpy(perm_text, "---");
2125  if(perm & Aaip_READ)
2126  perm_text[0]= 'r';
2127  if(perm & Aaip_WRITE)
2128  perm_text[1]= 'w';
2129  if(perm & Aaip_EXEC)
2130  perm_text[2]= 'x';
2131 
2132  type= (*rpt) >> 4;
2133  if(type == Aaip_FUTURE_VERSION) /* indicate to caller: version mismatch */
2134  {ret = -3; goto ex;}
2135 
2136  qualifier= !!((*rpt) & 8);
2137  if(qualifier) {
2138  ret= aaip_read_qualifier(rpt + 1, num_data - (rpt + 1 - data),
2139  name, name_size, &name_fill, 0);
2140  if(ret <= 0)
2141  {ret = -1; goto ex;}
2142  }
2143 
2144  /* Advance read pointer */
2145  (*consumed)+= 1 + (qualifier ? name_fill + 1 : 0);
2146  rpt+= 1 + (qualifier ? name_fill + 1 : 0);
2147 
2148  ret= 1;
2149  if(type == Aaip_TRANSLATE) {
2150  /* rightfully ignored yet */;
2151  continue;
2152  } else if(type == Aaip_ACL_USER_OBJ) {
2153  /* user::rwx */
2154  ret= aaip_write_acl_line(&wpt, &w_size, "user", "", perm_text, cnt);
2155  } else if(type == Aaip_ACL_USER) {
2156  /* user:<username>:rwx */;
2157  ret= aaip_write_acl_line(&wpt, &w_size, "user", name, perm_text, cnt);
2158  } else if(type == Aaip_ACL_GROUP_OBJ) {
2159  /* user::rwx */
2160  ret= aaip_write_acl_line(&wpt, &w_size, "group", "", perm_text, cnt);
2161  } else if(type == Aaip_ACL_GROUP) {
2162  /* group:<groupname>:rwx */;
2163  ret= aaip_write_acl_line(&wpt, &w_size, "group", name, perm_text, cnt);
2164  } else if(type == Aaip_ACL_MASK) {
2165  /* mask::rwx */
2166  ret= aaip_write_acl_line(&wpt, &w_size, "mask", "", perm_text, cnt);
2167  } else if(type == Aaip_ACL_OTHER) {
2168  /* other::rwx */
2169  ret= aaip_write_acl_line(&wpt, &w_size, "other", "", perm_text, cnt);
2170  } else if(type == Aaip_SWITCH_MARK) {
2171  /* Indicate to caller: end of desired ACL type access/default */
2172  if((perm & Aaip_EXEC) ^ (!!(flag & 2)))
2173  {ret= 2; goto ex;}
2174  } else if(type == Aaip_ACL_USER_N) {
2175  /* determine username from uid */
2176  uid= 0;
2177  for(i= 0; i < name_fill; i++)
2178  uid= (uid << 8) | ((unsigned char *) name)[i];
2179  pwd= getpwuid(uid);
2180  if(pwd == NULL)
2181  sprintf(name, "%.f", (double) uid);
2182  else if(strlen(pwd->pw_name) >= (size_t) name_size)
2183  sprintf(name, "%.f", (double) uid);
2184  else
2185  strcpy(name, pwd->pw_name);
2186  /* user:<username>:rwx */;
2187  ret= aaip_write_acl_line(&wpt, &w_size, "user", name, perm_text, cnt);
2188  } else if(type == Aaip_ACL_GROUP_N) {
2189  /* determine username from gid */;
2190  gid= 0;
2191  for(i= 0; i < name_fill; i++)
2192  gid= (gid << 8) | ((unsigned char *) name)[i];
2193  grp= getgrgid(gid);
2194  if(grp == NULL)
2195  sprintf(name, "%.f", (double) gid);
2196  else if(strlen(grp->gr_name) >= (size_t) name_size)
2197  sprintf(name, "%.f", (double) gid);
2198  else
2199  strcpy(name, grp->gr_name);
2200  /* user:<username>:rwx */;
2201  ret= aaip_write_acl_line(&wpt, &w_size, "group", name, perm_text, cnt);
2202  } else {
2203  /* indicate to caller: unknown type */
2204  {ret = -4; goto ex;}
2205  }
2206  if(ret <= 0)
2207  {ret = -2; goto ex;}
2208  }
2209  ret= 1;
2210 ex:;
2211  *acl_text_fill= w_size;
2212  if(flag & 1)
2213  (*acl_text_fill)++;
2214  LIBISO_FREE_MEM(name);
2215  return(ret);
2216 }
#define Aaip_ACL_USER_OBJ
Definition: aaip_0_2.c:48
#define Aaip_TRANSLATE
Definition: aaip_0_2.c:47
static int aaip_read_qualifier(unsigned char *data, size_t num_data, char *name, size_t name_size, size_t *name_fill, int flag)
Definition: aaip_0_2.c:2057
#define Aaip_SWITCH_MARK
Definition: aaip_0_2.c:54
#define Aaip_ACL_GROUP_OBJ
Definition: aaip_0_2.c:50
#define Aaip_READ
Definition: aaip_0_2.c:45
#define Aaip_ACL_OTHER
Definition: aaip_0_2.c:53
#define Aaip_ACL_USER_N
Definition: aaip_0_2.c:55
#define Aaip_ACL_GROUP_N
Definition: aaip_0_2.c:56
#define Aaip_EXEC
Definition: aaip_0_2.c:43
#define Aaip_ACL_MASK
Definition: aaip_0_2.c:52
#define Aaip_WRITE
Definition: aaip_0_2.c:44
#define Aaip_ACL_USER
Definition: aaip_0_2.c:49
#define Aaip_FUTURE_VERSION
Definition: aaip_0_2.c:57
static int aaip_write_acl_line(char **result, size_t *result_size, char *tag_type, char *qualifier, char *permissions, int flag)
Definition: aaip_0_2.c:2028
#define Aaip_ACL_GROUP
Definition: aaip_0_2.c:51
#define LIBISO_FREE_MEM(pt)
Definition: util.h:627
#define LIBISO_ALLOC_MEM(pt, typ, count)
Definition: util.h:615

References Aaip_ACL_GROUP, Aaip_ACL_GROUP_N, Aaip_ACL_GROUP_OBJ, Aaip_ACL_MASK, Aaip_ACL_OTHER, Aaip_ACL_USER, Aaip_ACL_USER_N, Aaip_ACL_USER_OBJ, Aaip_EXEC, Aaip_FUTURE_VERSION, Aaip_READ, aaip_read_qualifier(), Aaip_SWITCH_MARK, Aaip_TRANSLATE, Aaip_WRITE, aaip_write_acl_line(), LIBISO_ALLOC_MEM, and LIBISO_FREE_MEM.

Referenced by aaip_set_attr_list(), and iso_decode_acl().

◆ aaip_decode_attrs()

int aaip_decode_attrs ( struct aaip_state **  handle,
size_t  memory_limit,
size_t  num_attr_limit,
unsigned char *  data,
size_t  num_data,
size_t *  consumed,
int  flag 
)

Definition at line 1785 of file aaip_0_2.c.

1789 {
1790  int ret;
1791  struct aaip_state *aaip;
1792  size_t h_num, *h_lengths, i, new_mem, pair_consumed= 0;
1793  char **h_names, **h_values, *hpt;
1794 
1795  *consumed= 0;
1796  if(flag & (1 << 15)) {
1797  if(*handle == NULL)
1798  return(0);
1799  ret= aaip_get_decoded_attrs(handle, &h_num, &h_names, &h_lengths, &h_values,
1800  0);
1801  if(ret > 0)
1802  aaip_get_decoded_attrs(handle, &h_num, &h_names, &h_lengths, &h_values,
1803  1 << 15);
1804  if((*handle)->name_buf != NULL)
1805  free((*handle)->name_buf);
1806  if((*handle)->value_buf != NULL)
1807  free((*handle)->value_buf);
1808  free((char *) *handle);
1809  *handle= NULL;
1810  return(1);
1811  }
1812 
1813  aaip= *handle;
1814  if(aaip == NULL || (flag & 1)) {
1815  aaip= *handle= calloc(1, sizeof(struct aaip_state));
1816  if(*handle == NULL)
1817  return(-1);
1818  aaip_init_aaip_state(*handle, 0);
1819  }
1820  if(aaip->list_names == NULL || aaip->list_values == NULL ||
1821  aaip->list_value_lengths == NULL) {
1822  /* Initialize arrays */
1824  if(num_attr_limit > 0 && num_attr_limit < aaip->list_size)
1825  aaip->list_size= num_attr_limit;
1826  new_mem= aaip->list_size * (2*sizeof(char *) + sizeof(size_t)) +
1828  if(aaip->list_mem_used + new_mem >= memory_limit)
1829  return(3);
1830  aaip->list_mem_used+= new_mem;
1831  aaip->list_names= calloc(sizeof(char *), aaip->list_size);
1832  aaip->list_value_lengths= calloc(sizeof(size_t), aaip->list_size);
1833  aaip->list_values= calloc(sizeof(char *), aaip->list_size);
1834  if(aaip->list_names == NULL || aaip->list_value_lengths == NULL ||
1835  aaip->list_values == NULL)
1836  return(-1);
1837  for(i= 0; i < aaip->list_size; i++) {
1838  aaip->list_names[i]= NULL;
1839  aaip->list_value_lengths[i]= 0;
1840  aaip->list_values[i]= NULL;
1841  }
1842  }
1843  if(aaip->name_buf == NULL || aaip->value_buf == NULL) {
1845  if(aaip->list_mem_used >= memory_limit)
1846  return(3);
1847  aaip->list_mem_used+= new_mem;
1848  aaip->name_buf= calloc(1, Aaip_initial_name_leN);
1849  aaip->value_buf= calloc(1, Aaip_initial_value_leN);
1850  if(aaip->name_buf == NULL || aaip->value_buf == NULL)
1851  return(-1);
1854  }
1855 
1856  while(1) {
1857  if(aaip->list_pending_pair > 0) {
1858  /* the buffer holds a complete pair from a previous memory limit refusal */
1859  ret= aaip->list_pending_pair;
1860  aaip->list_pending_pair= 0;
1861  } else {
1862  ret= aaip_decode_pair(aaip, data, num_data, &pair_consumed,
1863  aaip->name_buf, aaip->name_buf_size, &aaip->name_buf_fill,
1864  aaip->value_buf, aaip->value_buf_size, &aaip->value_buf_fill,
1865  1);
1866  *consumed+= pair_consumed;
1867  }
1868  if(ret == -2) { /* insufficient result_size */
1869  if(aaip->first_is_name)
1870  ret= aaip_enlarge_buf(aaip, memory_limit, (size_t) 1, &(aaip->name_buf),
1871  &(aaip->name_buf_size), 0);
1872  else
1873  ret= aaip_enlarge_buf(aaip, memory_limit, (size_t) 1,
1874  &(aaip->value_buf), &(aaip->value_buf_size), 0);
1875  if(ret != 1)
1876  return(ret);
1877 
1878  } else if(ret == -1) { /* non-AAIP field detected */
1879  if(pair_consumed <= 0)
1880  return(-4); /* interpretation did not advance */
1881 
1882  } else if(ret < 0) { /* other error */
1883  return(-3);
1884 
1885  } else if(ret == 0) { /* first fetch pending pairs with num_data == 0 */
1886  /* should not happen, fetch more pairs */;
1887 
1888  } else if(ret == 1) {
1889  /* name and value are not valid yet, submit more data */
1890  return(1);
1891 
1892  } else if(ret == 2 || ret == 3 || ret == 4) {
1893  /* name and value are valid, submit more data */
1894  /* name and value are valid, pairs pending, fetch with num_data == 0 */
1895  /* name and value are valid, no more data expected */
1896  aaip->list_pending_pair= ret;
1897 
1898  if(aaip->list_num_attrs >= aaip->list_size) {
1899  hpt= (char *) aaip->list_names;
1900  ret= aaip_enlarge_buf(aaip, memory_limit, sizeof(char *),
1901  &hpt, &(aaip->list_size), 1);
1902  if(ret != 1)
1903  return(ret);
1904  aaip->list_names= (char **) hpt;
1905  hpt= (char *) aaip->list_values;
1906  ret= aaip_enlarge_buf(aaip, memory_limit, sizeof(char *),
1907  &hpt, &(aaip->list_size), 1);
1908  if(ret != 1)
1909  return(ret);
1910  aaip->list_values= (char **) hpt;
1911  hpt= (char *) aaip->list_value_lengths;
1912  ret= aaip_enlarge_buf(aaip, memory_limit, sizeof(size_t),
1913  &hpt, &(aaip->list_size), 0);
1914  if(ret != 1)
1915  return(ret);
1916  aaip->list_value_lengths= (size_t *) hpt;
1917  }
1918 
1919  /* Allocate name and value in list */;
1920  if(aaip->list_mem_used + aaip->name_buf_fill + aaip->value_buf_fill + 2
1921  > memory_limit) {
1922  return(3);
1923  }
1924  aaip->list_mem_used+= aaip->name_buf_fill + aaip->value_buf_fill + 2;
1925  i= aaip->list_num_attrs;
1926  aaip->list_names[i]= calloc(aaip->name_buf_fill + 1, 1);
1927  aaip->list_values[i]= calloc(aaip->value_buf_fill + 1, 1);
1928  memcpy(aaip->list_names[i], aaip->name_buf, aaip->name_buf_fill);
1929  aaip->list_names[i][aaip->name_buf_fill]= 0;
1930  memcpy(aaip->list_values[i], aaip->value_buf, aaip->value_buf_fill);
1931  aaip->list_values[i][aaip->value_buf_fill]= 0;
1932  aaip->list_value_lengths[i]= aaip->value_buf_fill;
1933  aaip->list_num_attrs++;
1934  aaip->name_buf_fill= aaip->value_buf_fill= 0;
1935 
1936  ret= aaip->list_pending_pair;
1937  aaip->list_pending_pair= 0;
1938 
1939  if(ret == 2)
1940  return(1);
1941  if(ret == 4)
1942  break;
1943 
1944  } else if(ret == 5)
1945  break;
1946  else
1947  return(-2);
1948 
1949  num_data= 0; /* consume pending pairs */
1950  }
1951  aaip->list_pending_pair= 5;
1952  return(2);
1953 }
static int aaip_enlarge_buf(struct aaip_state *aaip, size_t memory_limit, size_t item_size, char **buf, size_t *buf_size, int flag)
Definition: aaip_0_2.c:1735
#define Aaip_initial_list_sizE
Definition: aaip_0_2.c:1727
int aaip_init_aaip_state(struct aaip_state *aaip, int flag)
Definition: aaip_0_2.c:983
int aaip_get_decoded_attrs(struct aaip_state **handle, size_t *num_attrs, char ***names, size_t **value_lengths, char ***values, int flag)
Definition: aaip_0_2.c:1971
int aaip_decode_pair(struct aaip_state *aaip, unsigned char *data, size_t num_data, size_t *consumed, char *name, size_t name_size, size_t *name_fill, char *value, size_t value_size, size_t *value_fill, int flag)
Definition: aaip_0_2.c:1615
#define Aaip_initial_value_leN
Definition: aaip_0_2.c:1726
#define Aaip_initial_name_leN
Definition: aaip_0_2.c:1725
int first_is_name
Definition: aaip_0_2.c:940
size_t list_size
Definition: aaip_0_2.c:948
size_t * list_value_lengths
Definition: aaip_0_2.c:951
int list_pending_pair
Definition: aaip_0_2.c:959
char ** list_names
Definition: aaip_0_2.c:950
size_t value_buf_size
Definition: aaip_0_2.c:957
size_t list_mem_used
Definition: aaip_0_2.c:947
char * name_buf
Definition: aaip_0_2.c:953
char * value_buf
Definition: aaip_0_2.c:956
size_t name_buf_fill
Definition: aaip_0_2.c:955
size_t list_num_attrs
Definition: aaip_0_2.c:949
size_t value_buf_fill
Definition: aaip_0_2.c:958
size_t name_buf_size
Definition: aaip_0_2.c:954
char ** list_values
Definition: aaip_0_2.c:952

References aaip_decode_pair(), aaip_enlarge_buf(), aaip_get_decoded_attrs(), aaip_init_aaip_state(), Aaip_initial_list_sizE, Aaip_initial_name_leN, Aaip_initial_value_leN, aaip_state::first_is_name, aaip_state::list_mem_used, aaip_state::list_names, aaip_state::list_num_attrs, aaip_state::list_pending_pair, aaip_state::list_size, aaip_state::list_value_lengths, aaip_state::list_values, aaip_state::name_buf, aaip_state::name_buf_fill, aaip_state::name_buf_size, aaip_state::value_buf, aaip_state::value_buf_fill, and aaip_state::value_buf_size.

Referenced by iso_aa_get_attrs().

◆ aaip_decode_pair()

int aaip_decode_pair ( struct aaip_state aaip,
unsigned char *  data,
size_t  num_data,
size_t *  consumed,
char *  name,
size_t  name_size,
size_t *  name_fill,
char *  value,
size_t  value_size,
size_t *  value_fill,
int  flag 
)

Definition at line 1615 of file aaip_0_2.c.

1620 {
1621  int ret;
1622  size_t ready_bytes= 0;
1623 
1624 #ifdef Aaip_with_short_namespaceS
1625  char prefix[Aaip_max_name_expansioN + 1];
1626  size_t nl, pl;
1627 #endif
1628 
1629  *consumed= 0;
1630  if((aaip->pair_status < 0 && aaip->pair_status != -2) ||
1631  aaip->pair_status == 4 ||
1632  aaip->pair_status == 5) { /* dead ends */
1633  ret= aaip->pair_status;
1634  goto ex;
1635  } else if(aaip->pair_status == 2 || aaip->pair_status == 3) {
1636  if(aaip->pair_status == 3 && num_data > 0)
1637  {ret= 0; goto ex;}
1638  /* Start a new pair */
1639  if(!aaip->first_is_name) /* Eventually skip orphaned value */
1640  aaip_fetch_data(aaip, NULL, (size_t) 0, NULL, 1);
1641  *name_fill= *value_fill= 0;
1642  }
1643 
1644  if(num_data > 0) {
1645  ret= aaip_submit_data(aaip, data, num_data, &ready_bytes, 0);
1646  } else {
1647  ret= 1;
1648  if(aaip->num_components)
1649  ret= 3;
1650  else if(aaip->num_recs)
1651  ret= 2;
1652  }
1653  if(ret < 0) { /* non-AAIP field detected */
1654  *consumed= ready_bytes;
1655  {ret= -1; goto ex;}
1656  } else if(ret == 0) { /* buffer overflow */;
1657  /* should not happen with correct usage */
1658  {ret= -3; goto ex;}
1659  } else if(ret == 1) { /* no component record complete */
1660  goto ex;
1661  } else if(ret == 2) { /* component record complete, may be delivered */
1662  ;
1663  } else if(ret == 3) { /* component complete, may be delivered */
1664  ;
1665  } else if(ret == 4) { /* no component available, no more data expected */
1666  {ret= 5; goto ex;}
1667  } else
1668  {ret= -1; goto ex;} /* unknown reply from aaip_submit_data() */
1669 
1670  *consumed= num_data;
1671  ret= aaip_advance_pair(aaip, name, name_size - Aaip_max_name_expansioN,
1672  name_fill, value, value_size, value_fill, flag & 1);
1673  if(aaip->aa_ends == 3) {
1674  if(ret >= 2 && ret <= 4)
1675  ret= 4;
1676  else
1677  ret= 5;
1678  }
1679 ex:;
1680 
1681 #ifdef Aaip_with_short_namespaceS
1682 
1683  if(ret >= 2 && ret <= 4 && *name_fill > 0) {
1684  /* Translate name from eventual short form */
1685  nl= *name_fill;
1686  if(name[0] > 0 && name[0] <= Aaip_maxdef_namespacE) {
1687  prefix[0]= 0;
1688  if(name[0] == Aaip_namespace_literaL) {
1689  if(nl > 1) {
1690  /* Remove first character of name */
1691  memmove(name, name + 1, nl - 1);
1692  (*name_fill)--;
1693  }
1694  } else if(name[0] == Aaip_namespace_systeM ||
1695  name[0] == Aaip_namespace_useR ||
1696  name[0] == Aaip_namespace_isofS ||
1697  name[0] == Aaip_namespace_trusteD ||
1698  name[0] == Aaip_namespace_securitY
1699  ) {
1700  strcpy(prefix, Aaip_namespace_textS[(int) name[0]]);
1701  pl= strlen(prefix);
1702  memmove(name + pl, name + 1, nl - 1);
1703  memcpy(name, prefix, pl);
1704  *name_fill= pl + nl - 1;
1705  }
1706  }
1707  }
1708 
1709 #endif /* Aaip_with_short_namespaceS */
1710 
1711  aaip->pair_status= ret;
1712  return(ret);
1713 }
static int aaip_advance_pair(struct aaip_state *aaip, char *name, size_t name_size, size_t *name_fill, char *value, size_t value_size, size_t *value_fill, int flag)
Definition: aaip_0_2.c:1527
#define Aaip_namespace_trusteD
Definition: aaip_0_2.c:68
#define Aaip_namespace_systeM
Definition: aaip_0_2.c:65
int aaip_submit_data(struct aaip_state *aaip, unsigned char *data, size_t num_data, size_t *ready_bytes, int flag)
Definition: aaip_0_2.c:1371
#define Aaip_namespace_securitY
Definition: aaip_0_2.c:69
static char Aaip_namespace_textS[][9+1]
Definition: aaip_0_2.c:74
#define Aaip_max_name_expansioN
Definition: aaip_0_2.c:72
#define Aaip_namespace_isofS
Definition: aaip_0_2.c:67
#define Aaip_namespace_literaL
Definition: aaip_0_2.c:64
#define Aaip_maxdef_namespacE
Definition: aaip_0_2.c:62
int aaip_fetch_data(struct aaip_state *aaip, char *result, size_t result_size, size_t *num_result, int flag)
Definition: aaip_0_2.c:1432
#define Aaip_namespace_useR
Definition: aaip_0_2.c:66
unsigned int num_components
Definition: aaip_0_2.c:938
int aa_ends
Definition: aaip_0_2.c:921
unsigned int num_recs
Definition: aaip_0_2.c:934
int pair_status
Definition: aaip_0_2.c:943

References aaip_state::aa_ends, aaip_advance_pair(), aaip_fetch_data(), Aaip_max_name_expansioN, Aaip_maxdef_namespacE, Aaip_namespace_isofS, Aaip_namespace_literaL, Aaip_namespace_securitY, Aaip_namespace_systeM, Aaip_namespace_textS, Aaip_namespace_trusteD, Aaip_namespace_useR, aaip_submit_data(), aaip_state::first_is_name, aaip_state::num_components, aaip_state::num_recs, and aaip_state::pair_status.

Referenced by aaip_decode_attrs().

◆ aaip_encode()

ssize_t aaip_encode ( size_t  num_attrs,
char **  names,
size_t *  value_lengths,
char **  values,
size_t *  result_len,
unsigned char **  result,
int  flag 
)

Definition at line 100 of file aaip_0_2.c.

103 {
104  size_t mem_size= 0, comp_size;
105  ssize_t ret;
106  unsigned int number_of_fields, i, num_recs;
107 
108  /* Predict memory needs, number of SUSP fields and component records */
109  *result = NULL;
110  *result_len= 0;
111  for(i= 0; i < num_attrs; i++) {
112  ret= aaip_encode_pair(names[i], value_lengths[i], values[i],
113  &num_recs, &comp_size, NULL, (size_t) 0, 1);
114  if(ret < 0)
115  return(ret);
116  mem_size+= comp_size;
117  }
118  number_of_fields= mem_size / 250 + !!(mem_size % 250);
119  if(number_of_fields == 0)
120  return(0);
121  mem_size+= number_of_fields * 5;
122 
123 #ifdef Aaip_encode_debuG
124  *result= (unsigned char *) calloc(1, mem_size + 1024000);
125  /* generous honeypot for overflows */
126 #else
127  *result= (unsigned char *) calloc(1, mem_size);
128 #endif
129 
130  if(*result == NULL)
131  return ISO_OUT_OF_MEM;
132 
133  /* Encode pairs into result */
134  for(i= 0; i < num_attrs; i++) {
135  ret= aaip_encode_pair(names[i], value_lengths[i], values[i],
136  &num_recs, &comp_size, *result, *result_len, 0);
137  if(ret < 0) {
138  free(*result);
139  *result = NULL;
140  *result_len = 0;
141  return(ret);
142  }
143  (*result_len)+= comp_size;
144  }
145 
146  /* write the field headers */
147  for(i= 0; i < number_of_fields; i++) {
148  (*result)[i * 255 + 0]= 'A';
149  (*result)[i * 255 + 1]= 'L';
150  if(i < number_of_fields - 1 || (mem_size % 255) == 0)
151  (*result)[i * 255 + 2]= 255;
152  else
153  (*result)[i * 255 + 2]= mem_size % 255;
154  (*result)[i * 255 + 3]= 1;
155  (*result)[i * 255 + 4]= (flag & 1) || (i < number_of_fields - 1);
156  }
157  (*result_len)+= number_of_fields * 5;
158 
159 #ifdef Aaip_encode_debuG
160  if(*result_len != mem_size) {
161  fprintf(stderr, "aaip_encode(): MEMORY MISMATCH BY %d BYTES\n",
162  (int) (mem_size - *result_len));
163  } else {
164  unsigned char *hpt;
165  hpt= malloc(*result_len);
166  if(hpt != NULL) {
167  memcpy(hpt, *result, *result_len);
168  free(*result);
169  *result= hpt;
170  }
171  }
172  ret= 0;
173  for(i= 0; i < *result_len; i+= ((unsigned char *) (*result))[i + 2])
174  ret++;
175  if(ret != (int) number_of_fields) {
176  fprintf(stderr, "aaip_encode(): WRONG NUMBER OF FIELDS %d <> %d\n",
177  (int) number_of_fields, ret);
178  }
179 #endif /* Aaip_encode_debuG */
180 
181  return(number_of_fields);
182 }
static int aaip_encode_pair(char *name, size_t attr_length, char *attr, unsigned int *num_recs, size_t *comp_size, unsigned char *result, size_t result_fill, int flag)
Definition: aaip_0_2.c:226
#define ISO_OUT_OF_MEM
Memory allocation error (FATAL,HIGH, -6)
Definition: libisofs.h:8745

References aaip_encode_pair(), and ISO_OUT_OF_MEM.

Referenced by iso_node_set_attrs(), and lfs_get_aa_string().

◆ aaip_encode_acl()

int aaip_encode_acl ( char *  acl_text,
mode_t  st_mode,
size_t *  result_len,
unsigned char **  result,
int  flag 
)

Definition at line 292 of file aaip_0_2.c.

294 {
295  ssize_t bytes;
296 
297  *result= NULL;
298  *result_len= 0;
299  bytes= aaip_encode_acl_text(acl_text, st_mode,
300  (size_t) 0, NULL, 1 | (flag & (2 | 4 | 8 | 16)));
301  if(bytes < -2)
302  return(bytes);
303  if(bytes < 0)
304  return((int) bytes - 1);
305  if(flag & 1) {
306  *result_len= bytes;
307  return(1);
308  }
309  *result= calloc(bytes + 1, 1);
310  if(*result == NULL)
311  return(-1);
312  (*result)[bytes]= 0;
313  *result_len= bytes;
314  bytes= aaip_encode_acl_text(acl_text, st_mode, *result_len, *result,
315  (flag & (2 | 4 | 8 | 16)));
316  if(bytes < -2)
317  return(bytes);
318  if(bytes < 0)
319  return((int) bytes - 1);
320  if((size_t) bytes != *result_len) {
321  *result_len= 0;
322  return(-2);
323  }
324  return(1);
325 }
static ssize_t aaip_encode_acl_text(char *acl_text, mode_t st_mode, size_t result_size, unsigned char *result, int flag)
Definition: aaip_0_2.c:374

References aaip_encode_acl_text().

Referenced by aaip_encode_both_acl(), and aaip_get_attr_list().

◆ aaip_encode_both_acl()

int aaip_encode_both_acl ( char *  a_acl_text,
char *  d_acl_text,
mode_t  st_mode,
size_t *  result_len,
unsigned char **  result,
int  flag 
)

Definition at line 618 of file aaip_0_2.c.

620 {
621  int ret;
622  size_t a_acl_len= 0, d_acl_len= 0, acl_len= 0;
623  unsigned char *a_acl= NULL, *d_acl= NULL, *acl= NULL;
624 
625  if(a_acl_text != NULL) {
626  ret= aaip_encode_acl(a_acl_text, st_mode, &a_acl_len, &a_acl,
627  flag & (1 | 2 | 8 | 16));
628  if(ret <= 0)
629  goto ex;
630  }
631  if(d_acl_text != NULL) {
632  ret= aaip_encode_acl(d_acl_text, (mode_t) 0, &d_acl_len, &d_acl,
633  (flag & (1 | 2 | 16)) | 4);
634  if(ret <= 0)
635  goto ex;
636  }
637  if(a_acl == NULL || a_acl_len == 0) {
638  acl= d_acl;
639  d_acl= NULL;
640  acl_len= d_acl_len;
641  } else if (d_acl == NULL || d_acl_len == 0) {
642  acl= a_acl;
643  a_acl= NULL;
644  acl_len= a_acl_len;
645  } else {
646  acl= calloc(a_acl_len + d_acl_len, 1);
647  if(acl == NULL)
648  {ret = -1; goto ex;}
649  memcpy(acl, a_acl, a_acl_len);
650  memcpy(acl + a_acl_len, d_acl, d_acl_len);
651  acl_len= a_acl_len + d_acl_len;
652  }
653  *result= acl;
654  *result_len= acl_len;
655  ret= 1;
656 ex:;
657  if(a_acl != NULL)
658  free(a_acl);
659  if(d_acl != NULL)
660  free(d_acl);
661  return(ret);
662 }
int aaip_encode_acl(char *acl_text, mode_t st_mode, size_t *result_len, unsigned char **result, int flag)
Definition: aaip_0_2.c:292

References aaip_encode_acl().

Referenced by aaip_get_attr_list(), and iso_node_set_acl_text().

◆ aaip_fetch_data()

int aaip_fetch_data ( struct aaip_state aaip,
char *  result,
size_t  result_size,
size_t *  num_result,
int  flag 
)

Definition at line 1432 of file aaip_0_2.c.

1435 {
1436  int ret= -1, complete= 0, payload;
1437  unsigned int i, num_bytes= 0, h;
1438 
1439  if(aaip->num_recs == 0)
1440  return(-1);
1441 
1442  /* Copy data until end of buffer or end of component */
1443  h= 0;
1444  for(i= 0; i < aaip->num_recs && !complete; i++) {
1445  payload= aaip_get_buffer_byte(aaip, h + 1, 0);
1446  if(!(flag & 1)) {
1447  if(num_bytes + payload > result_size)
1448  return(-2);
1449  aaip_read_from_recs(aaip, h + 2, (unsigned char *) (result + num_bytes),
1450  payload, 0);
1451  *num_result= num_bytes + payload;
1452  }
1453  num_bytes+= payload;
1454  if(!(aaip_get_buffer_byte(aaip, h, 0) & 1))
1455  complete= 1;
1456  h+= payload + 2;
1457  }
1458  aaip->ready_bytes-= num_bytes;
1459  aaip->num_recs-= i;
1460 
1461  /* Shift buffer */
1462  aaip_shift_recs(aaip, h, 0);
1463 
1464  /* Compute reply */
1465  ret= 2 * !aaip->first_is_name;
1466  if(complete) {
1467  aaip->first_is_name= !aaip->first_is_name;
1468  if(aaip->num_components > 0)
1469  aaip->num_components--;
1470  } else
1471  ret|= 1;
1472 
1473  return(ret);
1474 }
static int aaip_read_from_recs(struct aaip_state *aaip, size_t idx, unsigned char *data, size_t num_data, int flag)
Definition: aaip_0_2.c:1087
static int aaip_shift_recs(struct aaip_state *aaip, size_t todo, int flag)
Definition: aaip_0_2.c:1127
static int aaip_get_buffer_byte(struct aaip_state *aaip, size_t idx, int flag)
Definition: aaip_0_2.c:1116
size_t ready_bytes
Definition: aaip_0_2.c:935

References aaip_get_buffer_byte(), aaip_read_from_recs(), aaip_shift_recs(), aaip_state::first_is_name, aaip_state::num_components, aaip_state::num_recs, and aaip_state::ready_bytes.

Referenced by aaip_advance_pair(), aaip_decode_pair(), and aaip_skip_component().

◆ aaip_get_acl_text()

int aaip_get_acl_text ( char *  path,
char **  text,
int  flag 
)

Definition at line 64 of file aaip-os-dummy.c.

65 {
66  return(0);
67 }

References aaip_cleanout_st_mode().

Referenced by aaip_get_attr_list(), and iso_local_get_acl_text().

◆ aaip_get_attr_list()

int aaip_get_attr_list ( char *  path,
size_t *  num_attrs,
char ***  names,
size_t **  value_lengths,
char ***  values,
int  flag 
)

Definition at line 74 of file aaip-os-dummy.c.

76 {
77  *num_attrs= 0;
78  *names= NULL;
79  *value_lengths= NULL;
80  *values= NULL;
81  return(1);
82 }

References aaip_encode_acl(), aaip_encode_both_acl(), and aaip_get_acl_text().

Referenced by iso_local_get_attrs(), and lfs_get_aa_string().

◆ aaip_get_decoded_attrs()

int aaip_get_decoded_attrs ( struct aaip_state **  handle,
size_t *  num_attrs,
char ***  names,
size_t **  value_lengths,
char ***  values,
int  flag 
)

Definition at line 1971 of file aaip_0_2.c.

1974 {
1975  size_t i;
1976  struct aaip_state *aaip;
1977 
1978  aaip= *((struct aaip_state **) handle);
1979  if(flag & (1 << 15)) {
1980  if(*names != NULL) {
1981  for(i= 0; i < *num_attrs; i++) {
1982  if((*names)[i] != NULL)
1983  free((*names)[i]);
1984  (*names)[i]= NULL;
1985  }
1986  free(*names);
1987  *names= NULL;
1988  }
1989  if(*values != NULL) {
1990  for(i= 0; i < *num_attrs; i++) {
1991  if((*values)[i] != NULL)
1992  free((*values)[i]);
1993  (*values)[i]= NULL;
1994  }
1995  free(*values);
1996  *values= NULL;
1997  }
1998  if(*value_lengths != NULL)
1999  free(*value_lengths);
2000  *value_lengths= NULL;
2001  *num_attrs= 0;
2002  return(1);
2003  }
2004 
2005  /* Check whether decoding is finished yet */
2006  if(aaip->list_pending_pair != 5)
2007  return(0);
2008 
2009  *num_attrs= aaip->list_num_attrs;
2010  *names= aaip->list_names;
2011  *value_lengths= aaip->list_value_lengths;
2012  *values= aaip->list_values;
2013 
2014  /* Now the memory is owned by the caller */
2015  aaip->list_num_attrs= 0;
2016  aaip->list_names= NULL;
2017  aaip->list_value_lengths= NULL;
2018  aaip->list_values= NULL;
2019  aaip->list_size= 0;
2020  aaip->list_pending_pair= 0;
2021  return(1);
2022 }

References aaip_state::list_names, aaip_state::list_num_attrs, aaip_state::list_pending_pair, aaip_state::list_size, aaip_state::list_value_lengths, and aaip_state::list_values.

Referenced by aaip_decode_attrs(), and iso_aa_get_attrs().

◆ aaip_get_pairs_skipped()

unsigned int aaip_get_pairs_skipped ( struct aaip_state aaip,
int  flag 
)

Definition at line 1716 of file aaip_0_2.c.

1717 {
1718  return(aaip->pairs_skipped);
1719 }
unsigned int pairs_skipped
Definition: aaip_0_2.c:944

References aaip_state::pairs_skipped.

◆ aaip_init_aaip_state()

int aaip_init_aaip_state ( struct aaip_state aaip,
int  flag 
)

Definition at line 983 of file aaip_0_2.c.

984 {
985  aaip->aa_head_missing= 5;
986  aaip->aa_missing= 0;
987 
988  aaip->recs_invalid= 0;
989  memset(aaip->recs, 0, Aaip_buffer_sizE + Aaip_buffer_reservE);
990  aaip->recs_fill= 0;
991  aaip->recs_start= aaip->recs;
992  aaip->rec_head_missing= 2;
993  aaip->rec_missing= 0;
994  aaip->rec_ends= 0;
995 
996  aaip->num_recs= 0;
997  aaip->ready_bytes= 0;
998 
999  aaip->num_components= 0;
1000  aaip->end_of_components= 0;
1001  aaip->first_is_name= 1;
1002 
1003  aaip->pair_status= 2;
1004  aaip->pairs_skipped= 0;
1005 
1006  aaip->list_mem_used= 0;
1007  aaip->list_size= 0;
1008  aaip->list_num_attrs= 0;
1009  aaip->list_names= NULL;
1010  aaip->list_value_lengths= NULL;
1011  aaip->list_values= NULL;
1012  aaip->name_buf= NULL;
1013  aaip->name_buf_size= 0;
1014  aaip->name_buf_fill= 0;
1015  aaip->value_buf= NULL;
1016  aaip->value_buf_size= 0;
1017  aaip->value_buf_fill= 0;
1018  aaip->list_pending_pair= 0;
1019  return(1);
1020 }
#define Aaip_buffer_reservE
Definition: aaip_0_2.c:913
#define Aaip_buffer_sizE
Definition: aaip_0_2.c:908
int rec_missing
Definition: aaip_0_2.c:930
int rec_head_missing
Definition: aaip_0_2.c:929
unsigned char * recs_start
Definition: aaip_0_2.c:928
int recs_invalid
Definition: aaip_0_2.c:925
size_t end_of_components
Definition: aaip_0_2.c:939
int aa_missing
Definition: aaip_0_2.c:920
int rec_ends
Definition: aaip_0_2.c:931
unsigned char recs[4096+(257+3 *2)]
Definition: aaip_0_2.c:926
size_t recs_fill
Definition: aaip_0_2.c:927
int aa_head_missing
Definition: aaip_0_2.c:919

References aaip_state::aa_head_missing, aaip_state::aa_missing, Aaip_buffer_reservE, Aaip_buffer_sizE, aaip_state::end_of_components, aaip_state::first_is_name, aaip_state::list_mem_used, aaip_state::list_names, aaip_state::list_num_attrs, aaip_state::list_pending_pair, aaip_state::list_size, aaip_state::list_value_lengths, aaip_state::list_values, aaip_state::name_buf, aaip_state::name_buf_fill, aaip_state::name_buf_size, aaip_state::num_components, aaip_state::num_recs, aaip_state::pair_status, aaip_state::pairs_skipped, aaip_state::ready_bytes, aaip_state::rec_ends, aaip_state::rec_head_missing, aaip_state::rec_missing, aaip_state::recs, aaip_state::recs_fill, aaip_state::recs_invalid, aaip_state::recs_start, aaip_state::value_buf, aaip_state::value_buf_fill, and aaip_state::value_buf_size.

Referenced by aaip_decode_attrs().

◆ aaip_local_attr_support()

int aaip_local_attr_support ( int  flag)

Definition at line 53 of file aaip-os-dummy.c.

54 {
55  return(0);
56 }

Referenced by iso_local_attr_support().

◆ aaip_set_acl_text()

int aaip_set_acl_text ( char *  path,
char *  text,
int  flag 
)

Definition at line 91 of file aaip-os-dummy.c.

92 {
93  return(0);
94 }

Referenced by aaip_set_attr_list(), and iso_local_set_acl_text().

◆ aaip_set_attr_list()

int aaip_set_attr_list ( char *  path,
size_t  num_attrs,
char **  names,
size_t *  value_lengths,
char **  values,
int *  errnos,
int  flag 
)

Definition at line 106 of file aaip-os-dummy.c.

109 {
110  size_t i;
111 
112  for(i= 0; i < num_attrs; i++)
113  errnos[i]= 0;
114 
115  for(i= 0; i < num_attrs; i++) {
116  if(names[i] == NULL || values[i] == NULL)
117  continue;
118  if(names[i][0] == 0) { /* ACLs */
119  if(flag & 1)
120  return(-7);
121  continue;
122  }
123  /* Extended Attribute */
124  if(flag & 4)
125  continue;
126  if(!(flag & 8))
127  if(strncmp(names[i], "user.", 5))
128  continue;
129  return(-6);
130  }
131  if(flag & 2)
132  return(-6);
133  return(1);
134 }

References aaip_decode_acl(), aaip_set_acl_text(), and register_errno().

Referenced by iso_local_set_attrs_errno().

◆ aaip_sizeof_aaip_state()

size_t aaip_sizeof_aaip_state ( void  )

Definition at line 977 of file aaip_0_2.c.

978 {
979  return((size_t) sizeof(struct aaip_state));
980 }

◆ aaip_skip_component()

int aaip_skip_component ( struct aaip_state aaip,
int  flag 
)

Definition at line 1487 of file aaip_0_2.c.

1488 {
1489  int to_skip= 1;
1490 
1491  if(aaip->first_is_name && !(flag & 1))
1492  to_skip= 2;
1493  if(aaip->recs_invalid) {
1494  aaip->recs_invalid+= to_skip;
1495  return(1);
1496  }
1497 
1498  if(aaip->num_components) {
1499  /* null-fetch */
1500  aaip_fetch_data(aaip, NULL, (size_t) 0, NULL, 1);
1501  to_skip--;
1502  }
1503  if(aaip->num_components && to_skip) {
1504  /* null-fetch */
1505  aaip_fetch_data(aaip, NULL, (size_t) 0, NULL, 1);
1506  to_skip--;
1507  }
1508  if(to_skip) {
1509  aaip->recs_fill= 0;
1510  aaip->num_recs= 0;
1511  aaip->ready_bytes= 0;
1512  }
1513  aaip->recs_invalid= to_skip;
1514  if(aaip->aa_ends == 2 && aaip->num_recs == 0)
1515  aaip->aa_ends= 3;
1516  return(1 + (aaip->num_recs > 0));
1517 }

References aaip_state::aa_ends, aaip_fetch_data(), aaip_state::first_is_name, aaip_state::num_components, aaip_state::num_recs, aaip_state::ready_bytes, aaip_state::recs_fill, and aaip_state::recs_invalid.

Referenced by aaip_advance_pair().

◆ aaip_submit_data()

int aaip_submit_data ( struct aaip_state aaip,
unsigned char *  data,
size_t  num_data,
size_t *  ready_bytes,
int  flag 
)

Definition at line 1371 of file aaip_0_2.c.

1374 {
1375  int ret;
1376  unsigned char *in_data;
1377 
1378  if(aaip->aa_ends == 3)
1379  return(4);
1380  in_data= data;
1381  if(num_data == 0)
1382  goto ex;
1383  if(aaip->recs_fill + num_data > Aaip_buffer_sizE)
1384  return(0);
1385 
1386  while(num_data > 0) {
1387  if(aaip->aa_head_missing > 0) {
1388  ret= aaip_consume_aa_head(aaip, &data, &num_data, 0);
1389  if(ret < 0) {
1390  *ready_bytes= data - in_data;
1391  return(-1);
1392  }
1393  if(num_data == 0 || aaip->aa_missing <= 0)
1394  goto ex;
1395  }
1396  aaip_consume_aa_data(aaip, &data, &num_data, 0);
1397  if(aaip->aa_missing)
1398  break;
1399  }
1400 ex:;
1401  *ready_bytes= aaip->ready_bytes;
1402  if(aaip->num_components > 0)
1403  return(3);
1404  if(aaip->num_recs > 0)
1405  return(2);
1406  if(aaip->aa_ends && aaip->aa_head_missing == 0 && aaip->aa_missing == 0)
1407  aaip->aa_ends= 2;
1408  if(aaip->aa_ends == 2 && aaip->num_recs == 0)
1409  aaip->aa_ends= 3;
1410  if(aaip->aa_ends == 3)
1411  return(4);
1412  return(1);
1413 }
static int aaip_consume_aa_head(struct aaip_state *aaip, unsigned char **data, size_t *num_data, int flag)
Definition: aaip_0_2.c:1265
static int aaip_consume_aa_data(struct aaip_state *aaip, unsigned char **data, size_t *num_data, int flag)
Definition: aaip_0_2.c:1295

References aaip_state::aa_ends, aaip_state::aa_head_missing, aaip_state::aa_missing, Aaip_buffer_sizE, aaip_consume_aa_data(), aaip_consume_aa_head(), aaip_state::num_components, aaip_state::num_recs, aaip_state::ready_bytes, and aaip_state::recs_fill.

Referenced by aaip_advance_pair(), and aaip_decode_pair().