summaryrefslogtreecommitdiff
path: root/libshouldbeinlibc/idvec.h
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-01-01 22:55:17 +0000
committerMiles Bader <miles@gnu.org>1996-01-01 22:55:17 +0000
commit94bb141afb6de09abca6731f11713dd62ff4a769 (patch)
treee9215673ef88886e5e2b0474eff447c8afe1924d /libshouldbeinlibc/idvec.h
parent12135a5bdf9e99418dfc08766f1697b34f89660d (diff)
(idvec_free_wrapper, idvec_free, idvec_ensure, idvec_grow,
idvec_tail_contains, idvec_add_new, idvec_insert_new, idvec_merge_ids, idvec_setid, idvec_merge_auth): New declarations.
Diffstat (limited to 'libshouldbeinlibc/idvec.h')
-rw-r--r--libshouldbeinlibc/idvec.h63
1 files changed, 59 insertions, 4 deletions
diff --git a/libshouldbeinlibc/idvec.h b/libshouldbeinlibc/idvec.h
index 4bd3ea5b..4bb86aa8 100644
--- a/libshouldbeinlibc/idvec.h
+++ b/libshouldbeinlibc/idvec.h
@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <errno.h>
+#include <hurd/hurd_types.h>
struct idvec
{
@@ -30,8 +31,37 @@ struct idvec
unsigned num, alloced;
};
-/* Return a new idvec, or NULL if there wasn't enough memory. */
-struct idvec *make_idvec ();
+/* Return a new, empty, idvec, or NULL if there wasn't enough memory. */
+struct idvec * make_idvec ();
+
+/* Free's IDVEC, but not the storage pointed to by the IDS field. */
+void idvec_free_wrapper (struct idvec *idvec);
+
+/* Frees IDVEC and any storage associated with it. */
+void idvec_free (struct idvec *idvec);
+
+/* Mark IDVEC as not containing any ids. */
+extern inline void
+idvec_clear (struct idvec *idvec)
+{
+ idvec->num = 0;
+}
+
+/* Ensure that IDVEC has enough spaced allocated to hold NUM ids, thus
+ ensuring that any subsequent ids added won't return a memory allocation
+ error unless it would result in more ids that NUM. ENOMEM is returned if
+ a memory allocation error occurs. */
+error_t idvec_ensure (struct idvec *idvec, unsigned num);
+
+/* Like idvec_ensure(), but takes INC, the increment of the number of ids
+ already in IDVEC as an argument. */
+error_t idvec_grow (struct idvec *idvec, unsigned inc);
+
+/* Returns true if IDVEC contains ID, at or after position POS. */
+int idvec_tail_contains (struct idvec *idvec, unsigned pos, uid_t id);
+
+/* Returns true if IDVEC contains ID. */
+int idvec_contains (struct idvec *idvec, uid_t id);
/* Insert ID into IDVEC at position POS, returning ENOMEM if there wasn't
enough memory, or 0. */
@@ -41,7 +71,32 @@ error_t idvec_insert (struct idvec *idvec, unsigned pos, uid_t id);
or 0. */
error_t idvec_add (struct idvec *idvec, uid_t id);
-/* Returns true if IDVEC contains ID. */
-int idvec_contains (struct idvec *idvec, uid_t id);
+/* If IDVEC doesn't contain ID, add it onto the end, returning ENOMEM if
+ there's not enough memory; otherwise, do nothing. */
+error_t idvec_add_new (struct idvec *idvec, uid_t id);
+
+/* If IDVEC doesn't contain ID at position POS or after, insert it at POS,
+ returning ENOMEM if there's not enough memory; otherwise, do nothing. */
+error_t idvec_insert_new (struct idvec *idvec, unsigned pos, uid_t id);
+
+/* Adds each id in the vector IDS (NUM elements long) to IDVEC, as if with
+ idvec_add_new(). */
+error_t idvec_merge_ids (struct idvec *idvec, uid_t *ids, unsigned num);
+
+/* EFF and AVAIL should be idvec's corresponding to a processes effective and
+ available ids. ID replaces the first id in EFF, and what it replaces is
+ preserved by adding it to AVAIL (if not already present). If SECURE is
+ non-NULL, and ID was not previously present in either EFF or AVAIL, then
+ *SECURE is set to true. ENOMEM is returned if a malloc fails, otherwise
+ 0. The return parameters are only touched if this call succeeds. */
+error_t idvec_setid (struct idvec *eff, struct idvec *avail, uid_t id,
+ int *secure);
+
+/* Add to all of EFF_UIDS, AVAIL_UIDS, EFF_GIDS, AVAIL_GIDS (as if with
+ idvec_merge) the ids associated with the auth port AUTH. Any of these
+ parameters may be NULL if that information isn't desired. */
+error_t idvec_merge_auth (struct idvec *eff_uids, struct idvec *avail_uids,
+ struct idvec *eff_gids, struct idvec *avail_gids,
+ auth_t auth);
#endif /* __IDVEC_H__ */