1 /* array.h -- definitions for the interface exported by array.c that allows
2 the rest of the shell to manipulate array variables. */
8 typedef int arrayind_t;
10 enum atype {array_indexed, array_assoc};
12 typedef struct array {
14 arrayind_t max_index, num_elements, max_size;
15 struct array_element *head;
18 typedef struct array_element {
21 struct array_element *next, *prev;
24 char *array_reference __P((ARRAY *, arrayind_t));
26 extern int array_add_element __P((ARRAY *, arrayind_t, char *));
27 extern ARRAY_ELEMENT *array_delete_element __P((ARRAY *, arrayind_t));
29 extern ARRAY_ELEMENT *new_array_element __P((arrayind_t, char *));
30 extern void destroy_array_element __P((ARRAY_ELEMENT *));
32 extern ARRAY *new_array __P((void));
33 extern void empty_array __P((ARRAY *));
34 extern void dispose_array __P((ARRAY *));
35 extern ARRAY *dup_array __P((ARRAY *));
36 extern ARRAY *dup_array_subrange __P((ARRAY *, ARRAY_ELEMENT *, ARRAY_ELEMENT *));
37 extern ARRAY_ELEMENT *new_array_element __P((arrayind_t, char *));
38 extern ARRAY_ELEMENT *copy_array_element __P((ARRAY_ELEMENT *));
40 extern WORD_LIST *array_to_word_list __P((ARRAY *));
41 extern ARRAY *word_list_to_array __P((WORD_LIST *));
42 extern ARRAY *assign_word_list __P((ARRAY *, WORD_LIST *));
44 extern char *array_to_assignment_string __P((ARRAY *));
45 extern char *quoted_array_assignment_string __P((ARRAY *));
46 extern char *array_to_string __P((ARRAY *, char *, int));
47 extern ARRAY *string_to_array __P((char *, char *));
49 extern char *array_subrange __P((ARRAY *, int, int, int));
50 extern char *array_pat_subst __P((ARRAY *, char *, char *, int));
52 extern ARRAY *array_quote __P((ARRAY *));
54 #define array_num_elements(a) ((a)->num_elements)
55 #define array_max_index(a) ((a)->max_index)
56 #define array_head(a) ((a)->head)
57 #define array_empty(a) ((a)->num_elements == 0)
59 #define element_value(ae) ((ae)->value)
60 #define element_index(ae) ((ae)->ind)
61 #define element_forw(ae) ((ae)->next)
62 #define element_back(ae) ((ae)->prev)
64 #define ALL_ELEMENT_SUB(c) ((c) == '@' || (c) == '*')
66 #endif /* _ARRAY_H_ */